万年历 找C高手帮我做课程设计

来源:百度知道 编辑:UC知道 时间:2024/06/24 10:39:06
题目:万年历
日常生活中离不开年历。编写程序要求当用户输入年份时能输出该年的日历,在日历上能够看出某天是星期几,可以显示任意一年任意一天,并能够知道是否是闰年等。

#include <stdio.h>

void main ()
{
int year, month, day, total, i;
int myts[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

printf("\nPlease input the Date(yyyy-mm-dd):");
scanf("%d-%d-%d", &year, &month, &day);

total = 0;
for (i = 1; i < month; i++)
{
total += myts[i];
}
total += day;

if (month > 2) /*如果是1月或是2月,则是否为闰年不影响*/
{
if ((year % 4 == 0 && year % 100 != 0) /*处理闰年*/
|| (year % 400 == 0))
{
total++;
printf("今年是闰年");
}
}

printf("\nthe Date %d-%02d-%02d is %dth day of year %d.",
year, month, day, total, year);
}
你的分就值这个程序了