求100行代码的C程序

来源:百度知道 编辑:UC知道 时间:2024/06/22 08:02:10
我是初学者,期末考试需要,要求我能看懂的,会分析的。

这个代码比100行多了一点。但是难度不大,我在关键地方都注释了。要是有看不懂的地方可以给我留言。随时帮你解答。
#include<stdio.h>
#include<stdlib.h>

char* month_str[]={"January","February","March","April","May","June","July","August","September","October","November","December"};
char* week[]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};

int IsLeapYear(int year) /*find out the year is leap year or not*/
{
if((year%4==0&&year%100!=0)||(year%400==0)) //这里是判断是否是闰年的
return 1; //如果是闰年就返回值1
else
return 0;//不是的话返回0

}
int month_day(int year,int month) //这个函数用来判断这年的月分有多少天的
{
int mon_day[]={31,28,31,30,31,30,31,31,30,31,30,31};
if(IsLeapYear(year)&&month==2) /*判断是判断是否是闰年,如果是闰年而且这个月是2月那这个月有29天*/
return 29;