1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
#include<conio.h>
#include<stdio.h>
#include<stdlib.h>
#define TRUE 1
#define FALSE 0
main()
{
/*int yrow=20,
int mrow=22,*/
int m=0,i;int day=1;
int week=6;
/*m,week and day are given initial values corresponding to 2011*/
int SR=8;//starting row for the main body of calender
int SC=8;//starting column for the main body of the calender
int diff;//difference between the year of calender sought and 2011
int leap;
int *cmonth=(int *)malloc(366);
int *cday=(int *)malloc(366);
int *cweek=(int *)malloc(366);
int year=2013;
/*m,day and week are integer variables
m=month ranging from 0-11
day=days varying from 1-28,30,29,31(dependeing upon month and year,leap or not)
weeek= symbolises week day from 0-6
respectively and is used to feed data into the pointer arrays which
contain the calender data cyear,cweek,cday;*/
clrscr();
diff=(2011-year);
if(year%4==0)
{leap=TRUE;}
else
{leap=FALSE;}
if(diff>0)
{week=6-(diff%7);}//starting value of week for the sought year
else
{week=6+(diff%7);}
i=0;
while(i!=(365+leap+1))
{cmonth[i]=m; cday[i]=day;day++;
if(m==0||m==2||m==4||m==6||m==7||m==9)
{if(day==32)
{m++;day=1;}
}
if(m==3||m==8||m==10||m==5)
{if(day==31){m++;day=1;}}
if(m==1&&leap==TRUE)
{if(day==30){m++;day=1;}}
if(m==1&&leap==FALSE)
{if(day==29){m++;day=1;}}
if(m==11&&day==32)
{break;}
if(week>6)
{week-=7;}
if(week<0)
{week+=7;}
cweek[i]=week;
week++;i++;
}
/*
writestring(mrow,SC+4,label_month[month],BLUE+GREEN);
gotoxy(yrow,SC+1);
textattr(BLUE+GREEN);
cprintf("%d",year);
textattr(BLUE+GREEN);
gotoxy(SR-1,SC);
cprintf(" S M T W T F S ");
j=0;*/
for(i=0;i<=365;i++)
{
printf("%d %d %d ",cday[i],cweek[i],cmonth[i]);
}
getch();
}
|