C语言用函数打印日历 c语言打印日历

c语言打印月历 怎么编写啊~ 谢谢!我这儿有一个万年历的程序,楼主可以试着编写实现你所需要的功能 。希望有所帮助 。
#includestdio.h
#includestdlib.h
int m[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int n[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};
char w[7][3]={"日","一","二","三","四","五","六"};
char mon[13][7]={"","一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"};
/*判断是否为闰年*/
int IsLeap(int year)
{
if((year%4==0year%100!=0)||(year%400==0))
return 1;
else
return 0;
}
/*计算某年某月某日是星期几*/
int Getweekday(int year,int month,int day)
{
int weekday;
int dayCount=0;
int i;
if(IsLeap(year))
{
for(i=1;imonth;i++)
dayCount+=n[i];
}
else
{
for(i=1;imonth;i++)
dayCount+=m[i];
}
dayCount=dayCount+day;
weekday=((year-1)+(year-1)/4-(year-1)/100+(year-1)/400+dayCount)%7;
return weekday;
}
/*判断某年某月某日是星期几的函数*/
void SelectDay()
{
int year,month,day;
char ch;
int weekday;
printf("请输入年月日(xxxx-xx-xx):\t");
scanf("%d-%d-%d",year,month,day);
weekday=Getweekday(year,month,day);
printf("\n");
printf("%d年%d月%d日是:星期%s\n",year,month,day,w[weekday]);
printf("\n您还需要继续查询吗?\t是(Y)/否(N)");
getchar();
ch=getchar();
if(ch=='y'||ch=='Y')
SelectDay();
}
/*输出某月的日历*/
void GetMonth(int year,int month )
{
int weekday,i,monthday;
weekday=Getweekday(year,month,1);
printf("日\t一\t二\t三\t四\t五\t六\n");
for(i=0;iweekday;i++)
printf("\t");
if(IsLeap(year))
monthday=n[month];
else
monthday=m[month];
for(i=1;i=monthday;i++)
{
printf("%2d\t",i);
weekday++;
if(weekday%7==0)
printf("\n");
}
printf("\n");
}
/*打印某年某月日历函数*/
void Month()
{
int year,month;
char ch;
printf("请输入年月(xxxx-xx):\t");
scanf("%d-%d",year,month);
printf("\n");
GetMonth(year,month );
printf("\n您还需要继续查询吗?\t是(Y)/否(N)");
getchar();
ch=getchar();
if(ch=='y'||ch=='Y')
Month();
}
【C语言用函数打印日历 c语言打印日历】/*打印某年日历函数*/
void Year()
{
int year,i;
char ch;
printf("请输入年份:\n");
scanf("%d",year);
for(i=1;i=12;i++)
{
printf("%s\n",mon[i]);
GetMonth(year,i);
printf("\n\n");
}
printf("\n您还需要继续查询吗?\t是(Y)/否(N)");
getchar();
ch=getchar();
if(ch=='y'||ch=='Y')
Year();
}
/*退出程序*/
void Exit()
{
char ch;
getchar();
printf("是否确定退出?\t是(Y)/否(N)");
ch=getchar();
if(ch=='y'||ch=='Y')
printf("感谢您的使用!!\n\n");
exit(0);
}
/*主函数*/
void main()
{
int choice;
while(1)
{
printf("欢迎使用该系统!!\n");
printf("**===**===**===**===**===**===**===**===**===**\n");
printf("1.查询某年某月某日是星期几\n");
printf("2.打印某年某月的全月日历\n");
printf("3.打印某年的全年日历\n");
printf("4.退出系统\n");
printf("**===**===**===**===**===**===**===**===**===**\n");
printf("请输入您需要进行的操作前面的序号: ");
scanf("%d",choice);
switch(choice)
{
case 1:SelectDay();break;
case 2:Month();break;

推荐阅读