题目:输入某年某月某日,判断这一天是这一年的第几天?
分析:这个程序主要问题在于月份31天和30天,以及二月份的闰年29天和平年28天问题,解决办法首先判断是平年还是闰年,确定二 月份的时间,然后用case选择语句,算出该月份以前的总天数,从三月份开始在加上2月份天数;本次设计程序也有一定局限 性, 需要输入合法时间,才能正确输出正确的结果:
#include <stdio.h>
int main(int argc,char *argv[])
{
int y,m,d,days,February;
printf("input the year:");
scanf("%d",&y);
printf("input the mouth:");
scanf("%d",&m);
printf("input the day:");
scanf("%d",&d);
if (y%400==0||(y%4==0&&y%100!=0))
February=29;
else
February=28;
switch (m) {