叶国富老婆杨云云:谁知道如何用C语言做2个圆和2条线,紧急~~

来源:百度文库 编辑:高考问答 时间:2024/05/09 04:24:59
知道的把程序复制上去哈~~

函数名: line
功 能: 在指定两点间画一直线
用 法: void far line(int x0, int y0, int x1, int y1);
程序例:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int xmax, ymax;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
/* an error occurred */
if (errorcode != grOk)
{
printf("Graphics error: %s\n",
grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1);
}

setcolor(getmaxcolor());
xmax = getmaxx();
ymax = getmaxy();

/* draw a diagonal line */
line(0, 0, xmax, ymax);

/* clean up */
getch();
closegraph();
return 0;
}

函数名: circle
功 能: 在给定半径以(x, y)为圆心画圆
用 法: void far circle(int x, int y, int radius);
程序例:

#include <graphics.h>
#include <stdlib.h>
#include <stdio.h>
#include <conio.h>

int main(void)
{
/* request auto detection */
int gdriver = DETECT, gmode, errorcode;
int midx, midy;
int radius = 100;

/* initialize graphics and local variables */
initgraph(&gdriver, &gmode, "");

/* read result of initialization */
errorcode = graphresult();
if (errorcode != grOk) /* an error occurred */
{
printf("Graphics error: %s\n", grapherrormsg(errorcode));
printf("Press any key to halt:");
getch();
exit(1); /* terminate with an error code */
}

midx = getmaxx() / 2;
midy = getmaxy() / 2;
setcolor(getmaxcolor());

/* draw the circle */
circle(midx, midy, radius);

/* clean up */
getch();
closegraph();
return 0;
}

#include<graphics.h>
main()
{
int driver,mode;
driver=DETECT;
mode=0;
initgraph(&driver,&mode,"");
setcolor(15);
line(0,0,0,0);
lineto(100,100);
lineto(200,0);
circle(100,100,20);
circle(100,100,40);
getch();
}

有专门的函数的吧