Tuesday, 26 July 2011

Works on C

Graphical Calendar display program using C..


#include<stdio.h>
#include<conio.h>
#include<bios.h>
#include<graphics.h>
#include<dos.h>
void mats(int,int,int,int);
int mat[110][110];
main()
{
int i,j,key=0,x,y,x1,x2,y1,y2,cnt=0;
union REGS in,o;

i=DETECT;
initgraph(&i,&j,"");
x=30;y=30;

while(key!=0x11b)
{
x1=50;x2=50;y1=20;y2=100;
/*four entries */
/********************/
for(i=0;i<3;i++)
{
line(x1,y1,x2,y2);
mats(x1,y1,x2,y2);
y1=y2+12;
y2=y2+90;
}
setbkcolor(1);
line(x1,y1,x2,y2);
mats(x1,y1,x2,y2);
arc(520,420,135,92,50);
outtextxy(510,420,"home");
/*********************doors*****************/
gotoxy(1,6);
printf("door 1");
gotoxy(1,12);
printf("door 2");
gotoxy(1,18);
printf("door 3");
/******************************************/
x1=50;x2=50;y1=20;y2=100;
line(50,20,80,20);
mats(50,20,80,20);
line(80,20,80,55);
mats(80,20,80,55);
line(95,35,95,70);
mats(95,35,95,70);
line(95,35,130,35);
mats(95,35,130,35);
line(130,35,130,50);
mats(130,35,130,50);
line(110,50,130,50);
mats(110,50,130,50);
line(110,50,110,100);
mats(110,50,110,100);
line(110,100,210,100);
mats(110,100,210,100);
line(210,35,210,100);
mats(210,35,210,100);
line(145,35,210,35);
mats(145,35,210,35);
line(145,50,210,50);
mats(145,50,210,50);
line(145,65,210,65);
mats(145,65,210,65);
line(145,80,210,80);
mats(145,80,210,80);
line(80,55,60,55);
mats(60,55,80,55);
line(70,70,95,70);
mats(70,70,95,70);
line(70,70,70,100);
mats(70,70,70,100);
line(70,100,100,100);
mats(70,100,100,100);
line(100,100,100,140);
mats(100,100,100,140);
line(50,112,85,112);
mats(50,112,85,112);
line(85,112,85,155);
mats(85,112,85,155);
line(85,155,215,155);
mats(85,155,215,155);
line(100,140,200,140);
mats(100,140,200,140);
line(215,125,215,155) ;
mats(215,125,215,155);
line(115,125,215,125);
mats(115,125,215,125);
line(100,110,230,110);
mats(100,110,230,110);
line(230,110,230,170);
mats(230,110,230,170);
line(65,170,230,170);
mats(65,170,230,170);
line(65,120,65,170);
mats(65,120,65,170);
line(50,190,130,190);
mats(50,190,130,190);
line(130,190,130,250);
mats(130,190,130,250);
line(130,250,245,250);
mats(130,250,245,250);
line(145,170,145,235);
mats(145,170,145,235);
line(160,170,160,235);
mats(160,170,160,235);
line(175,185,175,250);
mats(175,185,175,250);
rectangle(190,185,230,235);/********rectangle**********/
line(245,35,245,250);
mats(245,35,245,250);
line(230,20,230,110);
mats(230,20,230,110);
line(245,35,500,35);
mats(245,35,500,35);
line(230,20,515,20);
mats(230,20,515,20);
line(515,20,515,50);
mats(515,20,515,50);
line(260,50,515,50);
mats(260,50,515,50);
line(515,50,515,80);
mats(515,50,515,80);
line(245,65,500,65);
mats(245,65,500,65);
line(260,80,515,80);
mats(260,80,515,80);
line(260,80,260,235);
mats(260,80,260,235);
line(260,235,450,235);
mats(260,235,450,235);
line(245,250,465,250);
mats(245,250,465,250);
line(465,220,465,250);
mats(465,220,465,250);
line(275,220,465,220);
mats(275,220,465,220);
line(275,95,275,205);
mats(275,95,275,205);
line(275,95,500,95);
mats(275,95,500,95);
line(515,80,515,400);
mats(515,80,515,400);
line(500,95,500,400);
mats(500,95,500,400);
line(50,202,115,202);
mats(50,202,115,202);
line(115,202,115,265);
mats(115,202,115,265);
line(115,265,500,265);
mats(115,265,500,265);
line(465,110,465,220);
mats(465,110,465,220);
line(290,110,465,110);
mats(290,110,465,110);
line(275,125,450,125);
mats(275,125,450,125);
line(450,125,450,220);
mats(450,125,450,220);
line(435,140,435,220);
mats(435,140,435,220);
line(420,125,420,205);
mats(420,125,420,205);
line(405,140,405,220);
mats(405,140,405,220);
line(390,125,390,205);
mats(390,125,390,205);
line(375,140,375,220);
mats(375,140,375,220);
line(360,125,360,205);
mats(360,125,360,205);
line(345,140,345,220);
mats(345,140,345,220);
line(320,125,320,205);
mats(320,125,320,205);
line(305,140,305,220);
mats(305,140,305,220);
line(290,125,290,205);
mats(290,125,290,205);
line(80,20,250,20);
mats(80,20,250,20);
line(50,280,65,280);
mats(50,280,65,280);
line(65,215,65,280);
mats(65,215,65,280);
line(80,215,80,280);
mats(80,215,80,290);
line(50,292,80,292);
mats(50,292,80,292);
line(80,280,80,292);
mats(80,280,80,292);
line(95,202,95,305);
mats(95,202,95,305);
line(65,305,95,305);
mats(65,305,95,305);
line(65,305,65,355);
mats(65,305,65,355);
line(50,370,350,370);
mats(50,370,350,370);
line(65,355,335,355);
mats(65,355,335,355);
line(350,280,350,370);
mats(350,280,350,370);
line(80,340,350,340);
mats(80,340,350,340);
line(65,325,350,325);
mats(65,325,350,325);
line(110,310,350,310);
mats(110,310,350,310);
line(95,295,335,295);
mats(95,295,335,295);
line(365,265,365,355);
mats(365,265,365,355);
line(350,370,485,370);
mats(350,370,485,370);
line(380,280,380,370);
mats(380,280,380,370);
line(395,265,395,355);
mats(395,265,395,355);
line(410,280,410,370);
mats(410,280,410,370);
line(425,265,425,355);
mats(425,265,425,355);
line(440,280,440,370);
mats(440,280,440,370);
line(455,265,455,355);
mats(455,265,455,355);
line(470,280,470,370);
mats(470,280,470,370);
line(485,265,485,355);
mats(485,265,485,355);
line(485,370,485,415);
mats(485,370,485,415);

/*********************************************************
*********************************************************/
setcolor(15);
rectangle(0,0,getmaxx(),getmaxy());
setfillstyle(1,2);
fillellipse(x,y,5,5);

key=_bios_keybrd(_KEYBRD_READ);

if(key==0x4d00&&x<getmaxx()-5)
{
if(mat[(x+5)/5][y/5]!=1)
{
x=x+5; cnt++;
}
cleardevice();
}
if(key==0x4b00&&x>5)
{
if(mat[(x-5)/5][y/5]!=1)
{x=x-5;cnt++;}
cleardevice();
}
if(key==0x4800&&y>5)
{
if(mat[x/5][(y-5)/5]!=1)
{y=y-5;cnt++;}
cleardevice();
}
if(key==0x5000&&y<getmaxy()-5)
{
if(mat[x/5][(y+5)/5]!=1)
{y=y+5;cnt++;}
cleardevice();
}
gotoxy(67,4);
printf("move count");
gotoxy(70,6);
printf("%d",cnt);
/*succeessssssss*/

if(x>460&&y>400)
{
settextstyle(3,0,4);
setcolor(142);
outtextxy(200,200,"PERFECT!!!!!!");
setcolor(15);
settextstyle(0,0,0);
}
in.x.ax=1;
int86(0x33,&in,&o);
outtextxy(532,153,"RESTART");
rectangle(530,150,589,165);
in.x.ax=3;
int86(0x33,&in,&o);
if(o.x.bx==0&&o.x.cx>530&&o.x.cx<580&&o.x.dx>150&&o.x.dx<165)
{x=20,y=30; cleardevice();fillellipse(x,y,5,5);}

}}
void mats(int x1,int y1,int x2,int y2)
{
int s,t;
s=x1/5;t=y1/5;
if(x1==x2)
for(;t<=y2/5;t++)
mat[s][t]=1;
if(y1==y2)
for(;s<=x2/5;s++)
mat[s][t]=1;
}

3 comments: