当前位置:编程学习 > C/C++ >>

c语言中的时钟问题

我想知道 在界面上显示当时的时间怎么做,我想要完整的代码恩能执行的谢谢了啊
追问:不好运行啊  怎么出现 atal error C1083: Cannot open include file: 'graphics.h': No such file or directory这个啊???
答案:#include"stdio.h"    
#include"graphics.h"
#include"math.h"
#include"time.h"
#include"dos.h"

int point_sec,point_min,point_hour;
int x,y,z;
int array_sec[60][2];
int array_min[60][2];
int array_hour[60][2];
int a[60][2];


void zhongmian()
{
int n,m,p;
x=320;
y=240;
z=140;
point_sec=132;
point_min=110;
point_hour=90;
setfillstyle(1,2);
setlinestyle(0,0,3);
ellipse(x,y,0,180,220,150);
setlinestyle(0,0,3);
ellipse(x,y,180,360,220,150);
ellipse(x,y,90,270,210,150);
ellipse(x,y,90,270,200,150);
ellipse(x,y,90,270,190,150);
ellipse(x,y,90,270,180,150);
ellipse(x,y,90,270,170,150);
ellipse(x,y,90,270,160,150);
ellipse(x,y,90,270,150,150);
ellipse(x,y,270,90,150,150);
ellipse(x,y,270,90,160,150);
ellipse(x,y,270,90,170,150);
ellipse(x,y,270,90,180,150);
ellipse(x,y,270,90,190,150);
ellipse(x,y,270,90,200,150);
ellipse(x,y,270,90,210,150);
setcolor(3);
ellipse(x,80,25,155,72,72);
ellipse(x,80,40,140,55,55);
setcolor(RED);
circle(x,y,148);
floodfill(165,240,RED);
floodfill(145,240,RED);
floodfill(125,240,RED);
floodfill(105,240,RED);
floodfill(475,240,RED);
floodfill(495,240,RED);
floodfill(515,240,RED);
floodfill(535,240,RED);
setlinestyle(0,0,3);
line(135,320,90,420);
line(505,320,550,420);
line(90,420,550,420);
arc(x,y,26,154,200);
setcolor(YELLOW);
arc(x,y,32,147,192);
setcolor(YELLOW);
setfillstyle(1,1);
floodfill(250,400,RED);
putpixel(320,100,YELLOW);
fillellipse(320,100,5,5);
putpixel(390,119,YELLOW);
fillellipse(390,119,5,5);
putpixel(441,170,YELLOW);
fillellipse(441,170,5,5);
putpixel(460,240,YELLOW);
fillellipse(460,240,5,5);
putpixel(441,310,YELLOW);
fillellipse(441,310,5,5);
putpixel(390,361,YELLOW);
fillellipse(390,361,5,5);
putpixel(320,380,YELLOW);
fillellipse(320,380,5,5);
putpixel(250,361,YELLOW);
fillellipse(250,361,5,5);;
putpixel(199,310,YELLOW);
fillellipse(199,310,5,5);
putpixel(180,240,YELLOW);
fillellipse(180,240,5,5);;
putpixel(199,170,YELLOW);
fillellipse(199,170,5,5);;
putpixel(250,119,YELLOW);
fillellipse(250,119,5,5);;
for(p=6,n=0,m=0;n<15;p=p+6,n++,m++){
a[m][0]=(int)(x+z*sin(2*3.14*p/360));
a[m][1]=(int)(y-z*cos(2*3.14*p/360));

array_sec[m][0]=(int)(x+point_sec*sin(2*3.14*p/360));
array_sec[m][1]=(int)(y-point_sec*cos(2*3.14*p/360));

array_min[m][0]=(int)(x+point_min*sin(2*3.14*p/360));
array_min[m][1]=(int)(y-point_min*cos(2*3.14*p/360));

array_hour[m][0]=(int)(x+point_hour*sin(2*3.14*p/360));
array_hour[m][1]=(int)(y-point_hour*cos(2*3.14*p/360));
}
for(p=6,n=0;n<15;p=p+6,n++,m++){
a[m][0]=(int)(x+z*cos(2*3.14*p/360));
a[m][1]=(int)(y+z*sin(2*3.14*p/360));

array_sec[m][0]=(int)(x+point_sec*cos(2*3.14*p/360));
array_sec[m][1]=(int)(y+point_sec*sin(2*3.14*p/360));

array_min[m][0]=(int)(x+point_min*cos(2*3.14*p/360));
array_min[m][1]=(int)(y+point_min*sin(2*3.14*p/360));

array_hour[m][0]=(int)(x+point_hour*cos(2*3.14*p/360));
array_hour[m][1]=(int)(y+point_hour*sin(2*3.14*p/360));


}
for(p=6,n=0;n<15;p=p+6,n++,m++){
a[m][0]=(int)(x-z*sin(2*3.14*p/360));
a[m][1]=(int)(y+z*cos(2*3.14*p/360));

array_sec[m][0]=(int)(x-point_sec*sin(2*3.14*p/360));
array_sec[m][1]=(int)(y+point_sec*cos(2*3.14*p/360));

array_min[m][0]=(int)(x-point_min*sin(2*3.14*p/360));
array_min[m][1]=(int)(y+point_min*cos(2*3.14*p/360));

array_hour[m][0]=(int)(x-point_hour*sin(2*3.14*p/360));
array_hour[m][1]=(int)(y+point_hour*cos(2*3.14*p/360));


}
for(p=6,n=0;n<15;p=p+6,n++,m++){
a[m][0]=(int)(x-z*cos(2*3.14*p/360));
a[m][1]=(int)(y-z*sin(2*3.14*p/360));

array_sec[m][0]=(int)(x-point_sec*cos(2*3.14*p/360));
array_sec[m][1]=(int)(y-point_sec*sin(2*3.14*p/360));

array_min[m][0]=(int)(x-point_min*cos(2*3.14*p/360));
array_min[m][1]=(int)(y-point_min*sin(2*3.14*p/360));

array_hour[m][0]=(int)(x-point_hour*cos(2*3.14*p/360));
array_hour[m][1]=(int)(y-point_hour*sin(2*3.14*p/360));

}
for(n=0;n<60;n++)
putpixel(a[n][0],a[n][1],YELLOW);

}

void zhuandong()
{
struct tm * p;
time_t l;
int n,m,i,q,b,c,sec,min,hour;
n=61;
m=61;
i=61;
b=0;
c=0;

while(1){
l=time(NULL);
p=localtime(&l);
sec=p->tm_sec;
min=p->tm_min;
hour=p->tm_hour;
gotoxy(29,12);

if(n==sec){
setcolor(0);
setlinestyle(0,0,1);
line(x,y,array_sec[(sec+58)%60][0],array_sec[(sec+58)%60][1]);
setlinestyle(0,0,2);
line(x,y,array_min[(min+58)%60][0],array_min[(min+58)%60][1]);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+58)%60][0],array_hour[(hour%12*5+min/12+58)%60][1]);

setcolor(YELLOW);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+59)%60][0],array_hour[(hour%12*5+min/12+59)%60][1]);
setlinestyle(0,0,2);
line(x,y,array_min[(min+59)%60][0],array_min[(min+59)%60][1]);
printf("%s",asctime(p));
sound(50);
delay(100);
nosound();
setcolor(YELLOW);
setlinestyle(0,0,1);
line(320,240,array_sec[(sec+59)%60][0],array_sec[(sec+59)%60][1]);
}
n=sec+1;
if(n==60)n=0;

if(b==0)
{m=min;b=1;}
if(min==m){
setcolor(0);


setcolor(YELLOW);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+59)%60][0],array_hour[(hour%12*5+min/12+59)%60][1]);
setlinestyle(0,0,2);
line(x,y,array_min[(min+59)%60][0],array_min[(min+59)%60][1]);
}
m=min+1;
if(m==60)m=0;
if(c==0)
{i=min;c=1;}
if(i==min){
setcolor(0);
setcolor(YELLOW);
setlinestyle(0,0,3);
line(x,y,array_hour[(hour%12*5+min/12+59)%60][0],array_hour[(hour%12*5+min/12+59)%60][1]);

}
i=min+1;
if(i==60)i=0;
if(kbhit())exit(1);
}
}
main()
{
int gdriver,mode;
gdriver=VGA;
mode=VGAHI;
registerbgidriver(EGAVGA_driver);
initgraph(&gdriver,&mode,"");
setbkcolor(0);
setcolor(

上一个:C语言程序设计的相关软件!
下一个:求C语言经典三角程序

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,