首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

不会啊大侠帮忙啊同一平面上两个三角相交部分面积

2014-01-01 
不会啊,大侠帮忙啊,同一平面上两个三角形相交部分面积这个编程怎么实现啊#pragma comment(lib,user32)#p

不会啊,大侠帮忙啊,同一平面上两个三角形相交部分面积


不会啊大侠帮忙啊同一平面上两个三角相交部分面积

不会啊大侠帮忙啊同一平面上两个三角相交部分面积

不会啊大侠帮忙啊同一平面上两个三角相交部分面积

这个编程怎么实现啊

#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
HDC   hdc;
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = FALSE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void ShowTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = TRUE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void Area_of_intersected_triangle() {
    int n,k;
    HBRUSH hbrush;
    RECT   rect;
    struct P {int x,y;};
    struct T {
        struct P a,b,c;
    } t1,t2;
    char s[10];

    hbrush=CreateSolidBrush((COLORREF)0x00FFFFFF);
    n=1;
    while (1) {
        t1.a.x=5+rand()%296;
        t1.a.y=5+rand()%296;
        t1.b.x=5+rand()%296;
        t1.b.y=5+rand()%296;
        t1.c.x=5+rand()%296;
        t1.c.y=5+rand()%296;
        //TODO:确定三点能构成三角形(任意两边长度之和大于第三边长度)
        //TODO:三点的顺序按逆时针顺序排列

        t2.a.x=5+rand()%296;
        t2.a.y=5+rand()%296;
        t2.b.x=5+rand()%296;
        t2.b.y=5+rand()%296;
        t2.c.x=5+rand()%296;
        t2.c.y=5+rand()%296;
        //TODO:确定三点能构成三角形(任意两边长度之和大于第三边长度)
        //TODO:三点的顺序按逆时针顺序排列

        //判断两个三角形的位置关系:分离、包含、重合(顶点、边)、相交。包含时计算小三角形面积。相交时求出相交部分,并划分为最多四个小三角形求它们的面积和。

        sprintf(s,"%d",n);
        TextOut(hdc,10,10,s,strlen(s));
        MoveToEx(hdc,t1.a.x,t1.a.y,NULL);
          LineTo(hdc,t1.b.x,t1.b.y);
          LineTo(hdc,t1.c.x,t1.c.y);
          LineTo(hdc,t1.a.x,t1.a.y);
        MoveToEx(hdc,t2.a.x,t2.a.y,NULL);


          LineTo(hdc,t2.b.x,t2.b.y);
          LineTo(hdc,t2.c.x,t2.c.y);
          LineTo(hdc,t2.a.x,t2.a.y);
        k=getch();
        if (k==27) break;
        n++;
        rect.left=0;
        rect.top=0;
        rect.right=300;
        rect.bottom=300;
        FillRect(hdc, &rect, hbrush);
    }
    DeleteObject(hbrush);
}
int main() {
    HWND  hwnd;

    srand(time(NULL));
    system("color F0");
    system("cls");
    HideTheCursor();
    hwnd  = GetConsoleWindow();
    hdc   = GetDC(hwnd);
    Area_of_intersected_triangle();
    ReleaseDC(hwnd,hdc);
    system("color 07");
    system("cls");
    ShowTheCursor();
    return 0;
}


[解决办法]
http://msdn.microsoft.com/en-us/library/windows/desktop/ms683175(v=vs.85).aspx
[解决办法]


#pragma comment(lib,"user32")
#pragma comment(lib,"gdi32")
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <conio.h>
#include <time.h>
HDC   hdc;
HWND WINAPI GetConsoleWindow();
void HideTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = FALSE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void ShowTheCursor() {
    CONSOLE_CURSOR_INFO cciCursor;
    HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE);

    if(GetConsoleCursorInfo(hStdOut, &cciCursor)) {
        cciCursor.bVisible = TRUE;
        SetConsoleCursorInfo(hStdOut, &cciCursor);
    }
}
void Area_of_intersected_triangle() {
    int n,k;
    HBRUSH hbrush;
    RECT   rect;
    struct P {int x,y;};
    struct T {
        struct P a,b,c;
    } t1,t2;
    char s[10];

    hbrush=CreateSolidBrush((COLORREF)0x00FFFFFF);
    n=1;
    while (1) {
        t1.a.x=5+rand()%296;
        t1.a.y=5+rand()%296;
        t1.b.x=5+rand()%296;
        t1.b.y=5+rand()%296;
        t1.c.x=5+rand()%296;
        t1.c.y=5+rand()%296;
        //TODO:确定三点能构成三角形(任意两边长度之和大于第三边长度)
        //TODO:三点的顺序按逆时针顺序排列

        t2.a.x=5+rand()%296;
        t2.a.y=5+rand()%296;
        t2.b.x=5+rand()%296;
        t2.b.y=5+rand()%296;
        t2.c.x=5+rand()%296;
        t2.c.y=5+rand()%296;
        //TODO:确定三点能构成三角形(任意两边长度之和大于第三边长度)
        //TODO:三点的顺序按逆时针顺序排列



        //判断两个三角形的位置关系:分离、包含、重合(顶点、边)、相交。包含时计算小三角形面积。相交时求出相交部分,并划分为最多四个小三角形求它们的面积和。

        sprintf(s,"%d",n);
        TextOut(hdc,10,10,s,strlen(s));
        MoveToEx(hdc,t1.a.x,t1.a.y,NULL);
          LineTo(hdc,t1.b.x,t1.b.y);
          LineTo(hdc,t1.c.x,t1.c.y);
          LineTo(hdc,t1.a.x,t1.a.y);
        MoveToEx(hdc,t2.a.x,t2.a.y,NULL);
          LineTo(hdc,t2.b.x,t2.b.y);
          LineTo(hdc,t2.c.x,t2.c.y);
          LineTo(hdc,t2.a.x,t2.a.y);
        k=getch();
        if (k==27) break;
        n++;
        rect.left=0;
        rect.top=0;
        rect.right=300;
        rect.bottom=300;
        FillRect(hdc, &rect, hbrush);
    }
    DeleteObject(hbrush);
}
int main() {
    HWND  hwnd;

    srand(time(NULL));
    system("color F0");
    system("cls");
    HideTheCursor();
    hwnd  = GetConsoleWindow();
    hdc   = GetDC(hwnd);
    Area_of_intersected_triangle();
    ReleaseDC(hwnd,hdc);
    system("color 07");
    system("cls");
    ShowTheCursor();
    return 0;
}



赵老师不是我说你,你这干啥呢?
搞笑呢

这框架有用么?人家要的是具体算法的流程,你直接把todo里的给他不就行了?非要给个可执行代码,人家不做windows编程看这有用?

热点排行