附turboc2的下载:turboc2
c关于graphics.h库使用的方法:下载
高级编程技术:下载
画直线的代码:
1 #include "graphics.h"
2 main()
3 {
4 int i,gmode;
5 float x0,y0,y1,x1;
6 float j=12,k;
7 int gdriver=DETECT;
8 initgraph(&gdriver, &gmode, "");
9 printf("the graphics driver is %d, mode is %d\n", gdriver,
10 gmode);
11 setbkcolor(GREEN);
12 x0=263;y0=263;y1=275;x1=275;
13 for(i=0;i<=18;i++)
14 {
15 setcolor(5);
16 line(x0,y0,x0,y1);
17 x0=x0-5;
18 y0=y0-5;
19 x1=x1+5;
20 y1=y1+5;
21 j=j+10;
22 }
23 x0=263;y1=275;y0=263;
24 for(i=0;i<=20;i++)
25 {
26 setcolor(5);
27 line(x0,y0,x0,y1);
28 x0=x0+5;
29 y0=y0+5;
30 y1=y1-5;
31 }
32 }
2 main()
3 {
4 int i,gmode;
5 float x0,y0,y1,x1;
6 float j=12,k;
7 int gdriver=DETECT;
8 initgraph(&gdriver, &gmode, "");
9 printf("the graphics driver is %d, mode is %d\n", gdriver,
10 gmode);
11 setbkcolor(GREEN);
12 x0=263;y0=263;y1=275;x1=275;
13 for(i=0;i<=18;i++)
14 {
15 setcolor(5);
16 line(x0,y0,x0,y1);
17 x0=x0-5;
18 y0=y0-5;
19 x1=x1+5;
20 y1=y1+5;
21 j=j+10;
22 }
23 x0=263;y1=275;y0=263;
24 for(i=0;i<=20;i++)
25 {
26 setcolor(5);
27 line(x0,y0,x0,y1);
28 x0=x0+5;
29 y0=y0+5;
30 y1=y1-5;
31 }
32 }