[求助]为什么我这个程序运行时每隔几秒屏幕会花啊?该改什么地方啊?
# include <stdio.h># include <stdlib.h>
# include <conio.h>
# include<graphics.h>
# include<dos.h>
# include<math.h>
# include<complex.h>
# define pi 3.1415
void drawshizhen(int a) ;
void drawfenzhen(int b) ;
void drawmiaozhen(int c) ;
void main()
{
int gdriver=DETECT,gmode;
initgraph(&gdriver,&gmode,"d:\\tc\\BGI");
//cleardevice();
while(!kbhit()){
setwritemode(1);
srand(time(NULL));
int j;
struct time t;
gettime(&t);
printf("The current time is: %2d:%02d:%02d.%02d\n",t.ti_hour, t.ti_min, t.ti_sec, t.ti_hund);
gotoxy(0,0);
setcolor(BLUE);
setbkcolor(8);
circle(320,240,100);
rectangle(200,120,440,360);
char *s[12]={"1","2","3","4","5","6","7","8","9","10","11","12"};
settextjustify(0,0);
settextstyle(4,0,3);
int a=-30;
int heng[11];
int zhong[11];
double hudu;
int x,y,i;
for(i=11;i>=0;i--){
a=a+30;
hudu=2*pi*a/360;
x=320-120*sin(hudu);
heng[i]=x;
//printf("x=%d %d %d\n",x,a,hudu);
y=240-120*cos(hudu);
zhong[i]=y;
//printf("y=%d %d %d\n",y,a,hudu);
setcolor(RED);
outtextxy(x,y,s[i]);
}
drawshizhen(t.ti_hour);
drawfenzhen(t.ti_min);
drawmiaozhen(t.ti_sec);
gotoxy(0,0);
setwritemode(1);
srand(time(NULL));
delay(1000);
cleardevice();
}
getch();
closegraph();
}
//shizhen
void drawshizhen(int a)
{
int x,y;
setcolor(GREEN);
x=320+50*sin(2*pi*a/12);
y=240-50*cos(pi*a/120);
line(320,240,x,y);
}//line(320,240,heng[t.ti_hour],zhong[t.ti_hour]);
//fenzhen
void drawfenzhen(int b)
{
int x,y;
setcolor(YELLOW);
x=320+80*sin(2*pi*b/60);
y=240-80*cos(pi*b/30);
line(320,240,x,y);
}
//miaozhen
void drawmiaozhen(int c)
{
int x,y,z;
setcolor(WHITE);
x=320+100*sin(2*pi*c/60);
y=240-100*cos(2*pi*c/60);
line(320,240,x,y);
//cleardevice();
}