# 請問一下c的高手們,detect要include什麼檔

DETECT 要include 哪一個 .h 才能使用??

#include <stdio.h>

#include <graphics.h>

#include \"coordinate.h\" /* max X axis is 720 on MONO screen */

#define M 300

#include <conio.h>

#include <stdio.h>

#include <math.h>

#include <stdlib.h>

#include \"graphics.h\"

/* max Y axis is 347 on MONO screen */

int driver =DETECT, mode;

float THETA[N]; /* 存所有點至 B 點的角度 */

POINT t;

float theta(POINT p1, POINT p2);

main()

{

int i,j=0;

float temp;

initgraph(&driver, &mode, \"\"); /* */

for (i=0; i<N; i++)

THETA[i] = theta(polygon[1],polygon[i]);

/* 求出所有點至 B 點的角度大小 */

for (i=0; i<N; i++) /* 依所有點至B點的角度大小做排序*/

for (j=i+1; j<N; j++)

if (THETA[i] >THETA[j]) {

temp = THETA[i];

THETA[i] =THETA[j];

THETA[j] = temp;

t = polygon[i];

polygon[i] = polygon[j];

polygon[j] = t;

}

for (i=0; i<N-1; i++)

print_line(polygon[i],polygon[i+1]);

print_line(polygon[i],polygon[0]);

/* 繪出簡單封閉路徑圖 */

getch(); /* 暫停 */

closegraph(); /* 結束繪圖模式，回到文字模式 */

for (i=0; i<N ; i++) /* 印出在簡單封閉路徑上所有點 */

printf(\"\\n series%2d=%c\", i,polygon[i].c);

}

/*------------------------------------------------------*/

print_line(POINT p1, POINT p2)/*繪一直線經過p1點與p2點 */

{

int X = 23 ;

int Y = 15;

line(p1.x *X,M-p1.y *Y, p2.x * X+1,M-p2.y *Y+1);

line(p1.x *X,M-p1.y *Y, p2.x * X+1,M-p2.y *Y+1);

}

/*------------------------------------------------------*/

float theta(POINT p1, POINT p2)

{ /* 計算經過p1點至p2點之直線與水平線的交角 */

int dx, dy, ax, ay;

float temp;

dx = p2.x - p1.x; /* X 軸的變化量 */

ax = abs(dx);

dy = p2.y - p1.y; /* Y 軸的變化量 */

ay = abs(dy);

temp = (ax+ay ==0) ? 0 : (float) dy / (ax+ay);

if (dx<0) temp = 2 - temp;

else if (dy <0) temp = 4 + temp;

return temp * 90.0; /* 徑度轉成一般角度 */

}

Rating
• YuLing
Lv 4