/* Seven Segment Display
No. a b c d 1 2 3 4 5 6 7
-----------------------------------
0 0 0 0 0 1 1 1 1 1 1 0
1 0 0 0 1 0 1 1 0 0 0 0
2 0 0 1 0 1 1 0 1 1 0 1
3 0 0 1 1 1 1 1 1 0 0 1
4 0 1 0 0 0 1 1 0 0 1 1
5 0 1 0 1 1 0 1 1 0 1 1
6 0 1 1 0 1 0 1 1 1 1 1
7 0 1 1 1 1 1 1 0 0 0 0
8 1 0 0 0 1 1 1 1 1 1 1
9 1 0 0 1 1 1 1 1 0 1 1
*/
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
#include<graphics.h>
#include<dos.h>
#include<time.h>
#include<string.h>
#define ON LIGHTRED
#define OFF BLACK
#define CCOLOR BLUE
#define BLOWDELAY 11
#define BACKCOLOR LIGHTBLUE
int array[10][7]={
1,1,1,1,1,1,0,
0,1,1,0,0,0,0,
1,1,0,1,1,0,1,
1,1,1,1,0,0,1,
0,1,1,0,0,1,1,
1,0,1,1,0,1,1,
1,0,1,1,1,1,1,
1,1,1,0,0,0,0,
1,1,1,1,1,1,1,
1,1,1,1,0,1,1
};
void digital(int number,int c,int r)
{
int i=0;
setlinestyle(0,3,3);
setcolor(array[number][i]?ON:OFF);
i++;
line(c,r,c+45,r); // Segment 1
setcolor(array[number][i]?ON:OFF);
i++;
line(c+46,r+5,c+46,r+34); // Segment 2
setcolor(array[number][i]?ON:OFF);
i++;
line(c+46,r+45,c+46,r+74); // Segment 3
setcolor(array[number][i]?ON:OFF);
i++;
line(c,r+80,c+45,r+80); // Segment 4
setcolor(array[number][i]?ON:OFF);
i++;
line(c-1,r+45,c-1,r+74); // Segment 5
setcolor(array[number][i]?ON:OFF);
i++;
line(c-1,r+5,c-1,r+34); // Segment 6
setcolor(array[number][i]?ON:OFF);
i++;
line(c,r+40,c+45,r+40); // Segment 7
setlinestyle(0,3,1);
}
void balloon(int col,int row,int startrad,int endrad)
{
for(int r=startrad;r<=endrad;r++)
{
setcolor(CCOLOR);
circle(col,row,r);
delay(BLOWDELAY);
setcolor(BLACK);
circle(col,row,r);
}
for(r=endrad;r>=startrad;r--)
{
setcolor(CCOLOR);
circle(col,row,r);
delay(BLOWDELAY);
setcolor(BLACK);
circle(col,row,r);
}
}
void systime(void)
{
time_t timer;
struct tm *tblock;
/* gets time of day */
timer = time(NULL);
/* converts date/time to a structure */
tblock = localtime(&timer);
char c[50];
strcpy(c,asctime(tblock));
for(int i=11;i<20;i++)
{
printf("%c",c[i]);
}
}
void main()
{
clrscr();
int gd,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"");
delay(10);
// setbkcolor(BACKCOLOR);
for(int no=9;no>=0&&!kbhit();no--)
{
digital(no,getmaxx()/2-22,getmaxy()/2-37);
// setbkcolor(no);
delay(1500);
//balloon(getmaxx()/2,getmaxy()/2,70,200);
}
// balloon(130,130,5,120);
closegraph();
systime();
delay(500);
}
Share:
These icons link to social bookmarking sites where readers can share and discover new web pages.
