grok编程

2023-12-10 12:19:14 数码极客 bianji01

 

C 图形界面编程

说心里话,我以前也喜欢c的,不过太难了.这是一点东西.你可以实验以下的.c里的函数太多,你可以到新华书店去找书的,很多那方面的书.都很好,不过建议你学其他的语言,

函数名:line

功能:在指定两点间画一直线

用法:voidfarline(intx0,inty0,intx1,inty1);

#include

#include

#include

#include

intmain(void)

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intxmax,ymax;

/*initializegraphicsandlocalvariables*/

initgraph(&gdriver,&gmode,"");

/*readresultofinitialization*/

errorcode=graphresult();

/*anerroroccurred*/

if(errorcode!=grOk)

printf("Graphicserror:%s\n",

grapherrormsg(errorcode));

printf("Pressanykeytohalt:");

getch();

exit(1);

setcolor(getmaxcolor());

xmax=getmaxx();

ymax=getmaxy();

/*drawadiagonalline*/

line(0,0,xmax,ymax);

/*cleanup*/

getch();

closegraph();

return0;

函数名:linerel

功能:从当前位置点(CP)到与CP有一给定相对距离的点画一直线

用法:voidfarlinerel(intdx,intdy);

#include

#include

#include

#include

intmain(void)

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

charmsg[80];

/*initializegraphicsandlocalvariables*/

initgraph(&gdriver,&gmode,"");

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!=grOk)

printf("Graphicserror:%s\n",

grapherrormsg(errorcode));

printf("Pressanykeytohalt:");

getch();

exit(1);

/*movetheC.P.tolocation(20,30)*/

moveto(20,30);

/*createandoutputa

messageat(20,30)*/

sprintf(msg,"(%d,%d)",getx(),gety());

outtextxy(20,30,msg);

/*drawalinetOApointarelative

distanceawayfromthecurrent

valueofC.P.*/

linerel(100,100);

/*createandoutputamessageatC.P.*/

sprintf(msg,"(%d,%d)",getx(),gety());

outtext(msg);

/*cleanup*/

getch();

closegraph();

return0;

函数名:circle

功能:在给定半径以(x,y)为圆心画圆

用法:voidfarcircle(intx,inty,intradius);

#include

#include

#include

#include

intmain(void)

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intmidx,midy;

intradius=100;

/*initializegraphicsandlocalvariables*/

initgraph(&gdriver,&gmode,"");

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!=grOk)/*anerroroccurred*/

printf("Graphicserror:%s\n",grapherrormsg(errorcode));

printf("Pressanykeytohalt:");

getch();

exit(1);/*terminatewithanerrorcode*/

midx=getmaxx()/2;

midy=getmaxy()/2;

setcolor(getmaxcolor());

/*drawthecircle*/

circle(midx,midy,radius);

/*cleanup*/

getch();

closegraph();

return0;

函数名:cleardevice

功能:清除图形屏幕

用法:voidfarcleardevice(void);

#include

#include

#include

#include

intmain(void)

/*requestautodetection*/

intgdriver=DETECT,gmode,errorcode;

intmidx,midy;

/*initializegraphicsandlocalvariables*/

initgraph(&gdriver,&gmode,"");

/*readresultofinitialization*/

errorcode=graphresult();

if(errorcode!=grOk)/*anerroroccurred*/

printf("Graphicserror:%s\n",grapherrormsg(errorcode));

printf("Pressanykeytohalt:");

getch();

exit(1);/*terminatewithanerrorcode*/

midx=getmaxx()/2;

midy=getmaxy()/2;

setcolor(getmaxcolor());

/*forcenteringscreenmessages*/

settextjustify(CENTER_TEXT,CENTER_TEXT);

/*outputamessagetothescreen*/

outtextxy(midx,midy,"pressanykeytoclearthescreen:");

/*waitforakey*/

getch();

/*clearthescreen*/

cleardevice();

/*outputanothermessage*/

outtextxy(midx,midy,"pressanykeytoquit:");

/*cleanup*/

getch();

closegraph();

return0;

C语言编程 绘制曲线,会的来

TC下调试通过/********************************************************Author:Wacs5*Date:20090105(YYYY-MM-DD)*Function:画简易的曲线图 *********************************************************/#include #include #include #include #include #define n 8int main()int i,j;float data[]={7,3,12,6,9,5,8,11};char str[40];int gdrive=DETECT,gmode,errorcode;int maxx,maxy;int perx,pery;int x0,x1,y0,y1;int coLoraxis=2,colorline=3;float mindata,maxdata,ndata;initgraph(&gdrive,&gmode,"");/*初始化设备*/if ((errorcode=graphresult())!=grOk)/*查错*/printf("Graphics error:%s\nPress any key to exit:",grapherrormsg(errorcode));getch();exit(1);maxx=getmaxx();maxy=getmaxy();mindata=maxdata=data[0];for (i=1;idata[i])mindata=data[i];if (maxdata

声明:易趣百科所有作品(图文、音视频)均由用户自行上传分享,仅供网友学习交流。若您的权利被侵害,请联系315127732@qq.com
广告位招租
横幅广告