当前位置:三九宝宝网 → 宝宝教育 → 教学论文 → 正文

我想学C语言图形函数

更新:01-06 整理:39baobao.com
字体:

[用C语言写一个函数给出年月日计算该日是该年的第几天]//说明:你的程序存在几个语法错误,1、find(x,y,z)应改成find(int x,int y,int z)函数的定义语法;2、//int find(x,y,z);此处声明多余了,因为函数是在前面定义的,就无需再声明了,而...+阅读

函数名: line 功 能: 在指定两点间画一直线 用 法: void far line(int x0, int y0, int x1, int y1); 程序例: #include #include #include #include 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; } 函数名: linerel 功 能: 从当前位置点(CP)到与CP有一给定相对距离的点画一直线 用 法: void far linerel(int dx, int dy); 程序例: #include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; char msg[80]; /* initialize graphics and local variables */ initgraph(&gdriver, &gmode, ""); /* read result of initialization */ errorcode = graphresult(); if (errorcode != grOk) { printf("Graphics error: %s\n", grapherrormsg(errorcode)); printf("Press any key to halt:"); getch(); exit

(1); } /* move the C.P. to location (20, 30) */ moveto(20, 30); /* create and output a message at (20, 30) */ sprintf(msg, " (%d, %d)", getx(), gety()); outtextxy(20, 30, msg); /* draw a line to a point a relative distance away from the current value of C.P. */ linerel(100, 100); /* create and output a message at C.P. */ sprintf(msg, " (%d, %d)", getx(), gety()); outtext(msg); /* clean up */ getch(); closegraph(); return 0; } 函数名: circle 功 能: 在给定半径以(x, y)为圆心画圆 用 法: void far circle(int x, int y, int radius); 程序例: #include #include #include #include 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; } 函数名: cleardevice 功 能: 清除图形屏幕 用 法: void far cleardevice(void); 程序例: #include #include #include #include int main(void) { /* request auto detection */ int gdriver = DETECT, gmode, errorcode; int midx, midy; /* 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()); /* for centering screen messages */ settextjustify(CENTER_TEXT, CENTER_TEXT); /* output a message to the screen */ outtextxy(midx, midy, "press any key to clear the screen:"); /* wait for a key */ getch(); /* clear the screen */ cleardevice(); /* output another message */ outtextxy(midx, midy, "press any key to quit:"); /* clean up */ getch(); closegraph(); return 0; }

本文地址:https://www.39baobao.com/show/29_23959.html

以上内容来自互联网,请自行判断内容的正确性。若本站收录的信息无意侵犯了贵司版权,请联系我们,我们会及时处理和回复,谢谢.

以下为关联文档:

用c语言编写一个函数功能是算出每个月的天数int GetMonthDays(int year,int month) { switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: return 31; break; case 4: case 6: case 9: case...

C语言函数指针的调用问题?函数指针怎么用函数: int fun(int a,int b); 要定义指向该函数的指针 对比指向 int a; 的指针 int *p; p = &a; p的定义是怎么来的? 首先要保证p是一个指针类型 写下(*p), 然后,考虑下p的基类...

C语言指针以及函数调用#include void swap(int *p1,int *p2)//因为传入的数据类型为指针,所以修改了函数声明 { int p;//重复定义了p1,p2,删去了 p=*p1; *p1=*p2; *p2=p; } int main() { int n1,n2,n...

c语言求阶乘的函数阶乘: 阶乘是基斯顿·卡曼(Christian Kramp,1760~1826)于 1808 年发明的运算符号,是数学术语。 一个正整数的阶乘(英语:factorial)是所有小于及等于该数的正整数的积,并且有0的阶乘...

C语言返回指针的函数问题返回指针 要看这个局部指针变量在函数运行后 保存了哪个空间的地址了 指针里的值是可以返回的 就像你说的 “ return i,主调函数知道一个i就可以了 ” 同样主函数 知道一个指...

C语言返回指向数组的指针的函数第二种方法是因为类型不匹配(double*与(double(*)[ROW])产生错误,而且 ((double (*)[row])matrix); 里的[row]是一个变量,而指向数组的指针 double (*matrix)[ROW]里的ROW只能使...

怎么判断函数的奇偶性例如 y log3^xy 3^x怎么判断特别要说明的是函数的奇偶性只是单独对一个函数而言,而此题中的函数 y=log3^x y=3^x 是两个函数在其定义域内,只能说明是关于直线y=x对称,不能说成是奇偶性的。这两个函数都既...

高中函数的奇偶偶+偶=偶 奇+奇=奇 奇x偶=奇 奇x奇=偶 偶x偶=偶 增+增=增 减+减=增 增-减=减 减-增=减 就是同增异减 其他的没规律哦…… 应该没错吧 你等一下 我再查查…… 昕 17:30:54 增...

C语言中的图形函数有哪些一) 像素函数 putpiel() 画像素点函数 getpixel()返回像素色函数 (二) 直线和线型函数 line() 画线函数 lineto() 画线函数 linerel() 相对画线函数 setlinestyle() 设置线型函数 get...