谁来给我解决一下我写的这个日历
1.这个日历打印年不能全看见,只能看到后几个月2.选择2打印月,打印完毕时输入w就会出现输入Day输入完day后怎么什么都读不出来,主要就是帮我解决一下记事的这个功能。谢谢
#include<stdio.h>
#include "conio.h"
#include<stdlib.h>
#include <conio.h>
int e[] = {0,3,3,6,1,4,6,2,5,0,3,5};
char flag;
notebook(long date)
{
char note[1000];
FILE*fp;
fp=fopen;
if((fp=fopen("d:\\notebook.txt","a+"))==NULL)
{puts("This file can not be opened");exit(0);}
fscanf(fp,"%8s%s",date,¬e);
fprintf(fp,"%8s%s",date,note);
fclose(fp);
if((fp=fopen("d:\\notebook.txt","r"))==NULL)
{gets("This input file can not be opened");exit(0);}
fscanf(fp,"%8s%s",date,¬e);
fprintf(stdout," %8s %s",date,note);
fclose(fp);
}
print(int year,int month)
{
int i, j;
printf("MON\tTUE\tWEB\tTHU\tFRI\tSAT\t\SUN\n");
if(month==2)
{
if (year%4==0&&year%100!=0||year%100==0)
{
for(i=1;i<=29;i++)
{
int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
--rest;
rest%=7;
if(i==1) /* 确定1号打印的位置 */
{
if(rest==0) /*判断1号是否为星期日*/
{
printf("\t\t\t\t\t\t");
}
else
{
for(j=1;j<(rest%7);j++)
{
printf("\t");
}
}
}
printf("%d\t",i);
if(rest%7==0)
printf("\n");
}
}
else
{
for(i=1;i<=28;i++)
{
int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
rest%=7;
if(i==1) /* 确定1号打印的位置 */
{
if(rest==0) /*判断1号是否为星期日*/
{
printf("\t\t\t\t\t\t");
}
else
{
for(j=1;j<(rest%7);j++)
{
printf("\t");
}
}
}
printf("%d\t",i);
if(rest%7==0)
printf("\n");
}
}
}
else
{
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
for(i=1;i<=31;i++)
{
int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
rest%=7;
if(i==1) /* 确定1号打印的位置 */
{
if(rest==0) /*判断1号是否为星期日*/
{
printf("\t\t\t\t\t\t");
}
else
{
for(j=1;j<(rest%7);j++)
{
printf("\t");
}
}
}
printf("%d\t",i);
if(rest%7==0)
printf("\n");
}
}
else
{
for(i=1;i<=30;i++)
{
int rest=(i-1+e[month-1]+year+(year/4)-year/100+year/400);
rest%=7;
if(i==1) /* 确定1号打印的位置 */
{
if(rest==0) /*判断1号是否为星期日*/
{
printf("\t\t\t\t\t\t");
}
else
{
for(j=1;j<(rest%7);j++)
{
printf("\t");
}
}
}
printf("%d\t",i);
if(rest%7==0)
printf("\n");
}
}
}
printf("\n");
}
main()
{
int month,year,day,date;
char menu;
date=year*10000+month*100+day;
menu:
system("cls");
clreol();
printf("\n\t\t\t******************************\n");
printf("\t\t\t*\t Menu *\n");
printf("\t\t\t*\t1.Year Calender *\n");
printf("\t\t\t*\t2.Month Calender *\n");
/* printf("\t\t\t*\t3.Note Book *\n"); */
printf("\t\t\t*\t3.Exit *\n");
printf("\t\t\t******************************\n");
printf("\t\t\t* please enter selection *\n");
printf("\t\t\t******************************\n");
gotoxy(51,8);
while(1)
{
menu=getch();
switch(menu)
{
case'1':
system("cls");
clreol();
printf("\n\t\t\t******************************\n");
printf("\t\t\t*\t Menu *\n");
printf("\t\t\t*\t1.Year Calender *\n");
printf("\t\t\t*\t2.Month Calender *\n");
/* printf("\t\t\t*\t3.Note Book *\n"); */
printf("\t\t\t*\t3.Exit *\n");
printf("\t\t\t******************************\n");
printf("\t\t\t*\t year: *\n");
printf("\t\t\t******************************\n");
gotoxy(43,8);
scanf("%d",&year);
nextyear:
if(flag=='n'||flag=='N')
{
year+=1;
}
previousyear:
if(flag=='p'||flag=='P')
{
year-=1;
}
system("cls");
clreol();
for(month=1;month<13;month++)
{
printf("\t\t\tYear: %d\tMonth:%d\n",year,month);
print(year,month);
}
printf("Press M to Menu N to Nextyear P to Previousyear.\nAnykey to Exit!\n");
flag=getch();
if(flag=='m'||flag=='M')
{
goto menu;
}
else if(flag=='n'||flag=='N')
{
goto nextyear;
}
else if(flag=='p'||flag=='P')
{
goto previousyear;
}
else
return;
break;
case'2':
loop:
system("cls");
clreol();
printf("\n\t\t\t******************************\n");
printf("\t\t\t*\t Menu *\n");
printf("\t\t\t*\t1.Year Calender *\n");
printf("\t\t\t*\t2.Month Calender *\n");
/* printf("\t\t\t*\t3.Note Book *\n"); */
printf("\t\t\t*\t3.Exit *\n");
printf("\t\t\t******************************\n");
printf("\t\t\t* Year:\tMonth: *\n");
printf("\t\t\t******************************\n");
gotoxy(34, 8);
scanf("%d",&year);
gotoxy(47, 8);
scanf("%d",&month);
nextmonth:
if(month>12)
{
month=1;
year+=1;
}
previous:
if(month<1)
{
month=12;
year-=1;
}
system("cls");
clreol();
printf("\n\t\t\t******************************\n");
printf("\t\t\t*\t Menu *\n");
printf("\t\t\t*\t1.Year Calender *\n");
printf("\t\t\t*\t2.Month Calender *\n");
/* printf("\t\t\t*\t3.Note Book *\n"); */
printf("\t\t\t*\t3.Exit *\n");
printf("\t\t\t******************************\n");
printf("\t\t\t* Year:%d\tMonth:%d *\n",year,month);
printf("\t\t\t******************************\n");
print(year,month);
printf("\nPress M to Menu Space to Continue N to Nextmonth P to Previousmonth.\nAnykey to Exit!\n");
flag=getch();
if(flag==' ')
{
goto loop;
}
else if(flag=='n'||flag=='N')
{
year=year;
month+=1;
goto nextmonth;
}
else if(flag=='p'||flag=='P')
{
year=year;
month-=1;
goto previous;
}
else if(flag=='m'||flag=='M')
{
goto menu;
}
else if(flag=='w'||flag=='W')
{
system("cls");
clreol();
printf("\n\t\t\t******************************\n");
printf("\t\t\t*\t Menu *\n");
printf("\t\t\t*\t1.Year Calender *\n");
printf("\t\t\t*\t2.Month Calender *\n");
/* printf("\t\t\t*\t3.Note Book *\n"); */
printf("\t\t\t*\t3.Exit *\n");
printf("\t\t\t******************************\n");
printf("\t\t\t*\t Day: *\n");
printf("\t\t\t******************************\n");
gotoxy(42,8);
fscanf(stdin,"%d",&day);
notebook(date);
}
else
return;
break;
case'3':
return;
break;
}
}
}