老師讓我用c語言畫一個小球平拋軌跡圖#include <winbgim.h>#include <conio2.h>#include <math.h>#include <time.h>#define PI 3.1415926int main(){time_t now;int x,y;initwindow(1000,700); //open a 640x480 graphics windowsetcolor(WHITE); circle(100,50,10); //Draw a circlefloodfill(100,50,WHITE);//在圓內填充白色; bar(0,60,100,65);//上面板 bar(100,565,850,570);//下面板setcolor(WHITE);now=time(NULL); setwritemode(1);while(now==1000){x=100+100*now;y=50+(1/2)*10*now*now;setcolor(WHITE);cricle(x,y,10);delay(1000/24);cricle(x,y,10); }getch(); //wait for user to press a keyclosegraph(); //close graphics windowreturn 0;}
1 回答
蠱毒傳說
TA貢獻1895條經驗 獲得超3個贊
circle函數是TURBO C提供的圖形接口,用來畫圓。不屬于標準庫函數,不具備可移植性。
函數名:circle
功 能: 在給定半徑以(x, y)為圓心畫圓
用 法:void far circle(int x, int y, int radius)
隨時間變化,可以用cleardevice函數清除屏幕,不斷畫半徑不同的圓。看起來就像是一個隨時間變化的圓形。
函數名: cleardevice
功 能: 清除圖形屏幕
用 法: void far cleardevice(void);
例程:
#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());for(i=0;i<1000000;i++) if(i%50000==0){ cleardevice();/* clean the screen */ circle(midx, midy, radius--);/* draw the circle */}getch();closegraph();return 0;} |
- 1 回答
- 0 關注
- 223 瀏覽
添加回答
舉報
0/150
提交
取消
