#include<graphics.h>
#include<stdio.h>
#include<conio.h>
#include<dos.h>
void refresh(int x, int y)
{
setfillstyle(SOLID_FILL,BLACK);
bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
}
void LCD(int x, int y, int n)
{
refresh(x,y);
setfillstyle(SOLID_FILL,10);
switch(n)
{
case 0: bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
case 1: bar(39+x,7+y,44+x,57+y); //c
bar(39+x,66+y,44+x,116+y); //f
break;
case 2: bar(7+x,0+y,37+x,5+y); //a
//bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
bar(0+x,66+y,5+x,116+y); //e
//bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
case 3: bar(7+x,0+y,37+x,5+y); //a
//bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
//bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
case 4: //bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
//bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
//bar(7+x,118+y,37+x,123+y); //g
break;
case 5: bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
//bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
//bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
case 6: bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
//bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
case 7: bar(7+x,0+y,37+x,5+y); //a
//bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
//bar(7+x,59+y,37+x,64+y); //d
//bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
//bar(7+x,118+y,37+x,123+y); //g
break;
case 8: bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
case 9: bar(7+x,0+y,37+x,5+y); //a
bar(0+x,7+y,5+x,57+y); //b
bar(39+x,7+y,44+x,57+y); //c
bar(7+x,59+y,37+x,64+y); //d
//bar(0+x,66+y,5+x,116+y); //e
bar(39+x,66+y,44+x,116+y); //f
bar(7+x,118+y,37+x,123+y); //g
break;
}
}
void blink(int color)
{
setcolor(color);
setfillstyle(SOLID_FILL, color);
circle(320,280,4);
circle(320,320,4);
floodfill(320,280,color);
floodfill(320,320,color);
}
void clock(int t1, int t2, int t3, int t4)
{
int i=0;
while(1)
{
if(i==60)
{
i=0;
t4++;
}
LCD(200,240,t1);
LCD(250,240,t2);
LCD(350,240,t3);
LCD(400,240,t4);
blink(BLACK);
delay(700);
blink(10);
delay(200);
i++;
if(t1>=2 && t2>=3 && t3>=5 && t4>=9)
t1=t2=t3=t4=0;
if(t4==10)
{
t4=0;
t3++;
if(t3==5)
{
t3=0;
if(t1!=2 && t2!=3)
{
t2++;
if(t2 == 10)
{
t2=0;
t1++;
}
}
}
}
}
}
void main()
{
int gm, gd = DETECT,time,t1,t2,t3,t4;
initgraph(&gd, &gm, "..//bgi");
cleardevice();
printf("Enter Time: ");
scanf("%d",&time);
t4=time%10;
time/=10;
t3=time%10;
time/=10;
t2=time%10;
t1=time/10;
//printf("%d\t%d\t%d\t%d",t1,t2,t3,t4);
clock(t1,t2,t3,t4);
getch();
closegraph();
}
No comments:
Post a Comment