Professional Documents
Culture Documents
h>
#include<fstream.h>
#include<string.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
#define LEAP_YEAR ((Year%4==0 && Year%100 != 0)||Year%400==0)
getkey()
{
union REGS i,o;
while(!kbhit());
i.h.ah = 0;
int86(22,&i,&o);
return (o.h.ah);
}
/*================ FUNCTION TO CALCULATE ZELLER'S ALGORITHM =============*/
int getZeller(int Month,int Year)
{
int Day = 1, ZMonth, ZYear, Zeller;
if(Month < 3)
ZMonth = Month+10;
else
ZMonth = Month-2;
if(ZMonth > 10)
ZYear = Year-1;
else
ZYear = Year;
Zeller = ((int)((13*ZMonth-1)/5)+Day+ZYear%100+
(int)((ZYear%100)/4)-2*(int)(ZYear/100)+
(int)(ZYear/400)+77)%7;
return Zeller;
}
/*=======================================================================*/
void PrintFile(int M,int Y, int Z)
{
int i,j;
char filename[12];
char stryear[5];
ifstream stream;
strcpy(filename,MonthName1[M-1]);
itoa(Y,stryear,10);
strcat(filename,stryear);
strcat(filename,".txt");
if(!stream)
{
cout<<"\nError-cannot create file.";
getch();
exit(1);
}
cout<<"\n\t\t\t"<<MonthName[M-1]<<" "<<Y<<"\n\n\t";
for(i=1;i<=100;i++)
cout<<"-";
cout<<"\n\tSUN\tMON\tTUE\tWED\tTHU\tFRI\tSAT\n\t";
for(i=1;i<=100;i++)
cout<<"-";
/* setting starting position */
cout<<"\n";
for(i = 1; i <= Z; i++)
cout<<"\t -";
j = Z;
/* printing dates */
for(i = 1; i <= MonthDay[M-1]; i++)
{
if(j++ % 7 == 0)
cout<<"\n";
cout<<"\t "<<i;
}
cout<<"\n\t";
for(i=1;i<=100;i++)
cout<<"-";
stream.close();
}
void printchar(char c)
{
int i=1;
cout<<"\n\t";
for(i=1;i<=51;i++)
cout<<c;
cout<<"\n";
/* giving output */
printchar('-');
textcolor(12); /* LIGHTRED */
cout<<"\t";
cprintf("SUN");
textcolor(LIGHTGREEN);
cprintf(" MON TUE WED THU FRI SAT");
textcolor(7);
printchar('-');
printchar('-');
cout<<"\n\n\t\t(*) Use Left,Right,Up & Down Arrow.";
cout<<"\n\n\t\t(*) Press I for New Month & Year.";
cout<<"\n\n\t\t(*) Press P for Print to File.";
cout<<"\n\n\t\t(*) Press ESC for Exit.\n\n\n\t\t";
textcolor(WHITE);
textbackground(BLACK);