阿笨2588 阿笨2588
关注数: 3 粉丝数: 7 发帖数: 729 关注贴吧数: 5
各位高手帮一下:整点报时咋结束不了呢??? #include "graphics.h"#define PI 3.1416#include "math.h"#include "dos.h" main(){ int x0=320,y0=240,r0=150; void init_sceen(); void sec(); init_sceen(x0,y0,r0); sec(); closegraph(); getch();} void init_sceen(int x0,int y0,int r0) { int i,x,y,graphdriver,graphmode; char s[10]; float alpha,a0=90; registerbgidriver(EGAVGA_driver); graphdriver=DETECT; initgraph(&graphdriver,&graphmode,""); cleardevice(); setbkcolor(0); setcolor(5); circle(x0,y0,r0); circle(x0,y0,r0+30); setfillstyle(SOLID_FILL,12); floodfill(x0-r0-10,y0,5); for(i=12;i>=1;i--) { alpha=(a0+30*(12-i))*PI/180; x=x0+cos(alpha)*r0-16; y=y0-sin(alpha)*r0; sprintf(s,"%2d",i); setcolor(7); settextstyle(0,0,2); outtextxy(x,y,s); } for(i=60;i>=1;i--) { alpha=(a0+6*(60-i))*PI/180; x=x0+cos(alpha)*(r0-20); y=y0-sin(alpha)*(r0-20); setcolor(14); if(i%5==0) circle(x,y,5); else circle(x,y,2); floodfill(x,y,14); } setlinestyle(0,0,3); }void sec(void){ int x,y,i,j,k,xi,xj,xk,yi,yj,yk,x0=320,y0=240,r0=150; union REGS r; unsigned char *shijian="\n\n\n\n\n\n\n\n\n\n\n\n"; char *riqi="\n\n\n\n\n\n\n\n\n\n\n"; struct time tim; struct date dat; float alphai,alphaj,alphak,a0=90; xi=x0;yi=y0;xj=x0;yj=y0;xk=x0;yk=y0; do { x=38;y=12; gettime(&tim); sprintf(shijian,"%02d:%02d:%02d",tim.ti_hour,tim.ti_min,tim.ti_sec); setfillstyle(SOLID_FILL,0); bar(245,190,375,210); setcolor(WHITE); outtextxy(245,190,shijian); getdate(&dat); sprintf(riqi,"%02d-%02d-%02d",dat.da_year,dat.da_mon,dat.da_day); setfillstyle(SOLID_FILL,0); bar(245,290,375,310); setcolor(WHITE); outtextxy(245,290,riqi); x=190; y=430; setcolor(YELLOW); outtextxy(x,y,"Designed by wangtao"); setlinestyle(0,0,3); k=tim.ti_hour; j=tim.ti_min; i=tim.ti_sec; if(tim.ti_min==0) /*整点报时功能*/ { sound(688); sleep(1); nosound(); } alphak=(a0+30*(12-k)-j*5/60*6)*PI/180; alphaj=(a0-6*j)*PI/180; /*画出秒针*/ alphai=(a0+6*(60-i))*PI/180; x=x0+cos(alphai)*(r0-35); y=y0-sin(alphai)*(r0-35); setcolor(BLACK); line(x0,y0,xi,yi); setcolor(LIGHTRED); line(x0,y0,x,y); xi=x; yi=y; /*画出分针*/ x=x0+cos(alphaj)*(r0-45); y=y0-sin(alphaj)*(r0-45); setcolor(BLACK); line(x0,y0,xj,yj); setcolor(LIGHTRED); line(x0,y0,x,y); xj=x; yj=y; /*画出时针*/ x=x0+cos(alphak)*(r0-65); y=y0-sin(alphak)*(r0-65); setcolor(BLACK); line(x0,y0,xk,yk); setcolor(LIGHTRED); line(x0,y0,x,y); xk=x; yk=y; /* sound(984);*/ /*秒针走时的滴答声*/ /*sleep(1); */ /*nosound();*/ delay(10000); } while(!kbhit());}
1 下一页