C语言题目求教

[复制链接]
查看11 | 回复0 | 2007-6-24 11:17:04 | 显示全部楼层 |阅读模式
#include "time.h"#include "stdio.h"int IsLeapYear(int year){ if((year%4==0)&&(year%100!=0)||year%400==0)
return 1; else
return 0;}int JudgeWeek(int year,int month){/*//// 1900 年 1 月 1 日
星期一*/int leapdays[13]={0,31,29,31,30,31,30,31,31,30,31,30,31};int a[13];int sum,total;sum=0;a[0]=0;sum=0;for(int i=1;itm_wday; if(i==0)return "星期天"; else if(i==1)return "星期一"; else if(i==2)return "星期二"; else if(i==3)return "星期三"; else if(i==4)return "星期四"; else if(i==5)return "星期五"; elsereturn "星期六";}void DisplayCalendar(){ time_t t; struct tm *current; time(&t); int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31},week,i; int month,year; current=localtime(&t); month=current->tm_mon+1; year=current->tm_year+1900; week=JudgeWeek(year,month); if(IsLeapYear(year)&&month==2)
a[2]=29; printf("
%d 年
%d 月 \n",year,month);
printf("%4s%4s%4s%4s%4s%4s%4s\n","Sun","Mon","Tue","Wed","Thu","Fri","Sat");if(week==7)
goto loop2;for(i=0;itm_year,current->tm_mon+1,current->tm_mday,workday()); printf("Current Time: %d:%d:%d\n",current->tm_hour,current->tm_min,current->tm_sec); DisplayCalendar();}将日历写到文本文件不难,这里就不给出代码了。第三小题答案有了,第四小题也就容易了。参考资料:http://hi.baidu.com/ctralt/blog/item/ee937c167e87db4b21a4e96b.html
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行