1.#include <stdio.h>
void main()
{
int day=0,month,year,sum=0,temp=0;
printf("\nplease input year,month,day\n");
scanf("%4d,%2d,%2d",&year,&month,&day);
if((year%400==0)||(year%4==0&&year%100!=0))
temp=1;
if(month<0&&month>12)
{
printf("The month is erroy.Put the number");
scanf("%d",&month);
}
if(day<0&&day>31||(month>2&&day>28)||(temp=1&&month>29))
{
printf("The day is erroy.Put the number");
scanf("%d",&day);
}
switch(month)/*先计算某月以前月份的总天数*/
{
case 1:sum=0;break;
case 2:sum=31;break;
case 3:sum=59;break;
case 4:sum=90;break;
case 5:sum=120;break;
case 6:sum=151;break;
case 7:sum=181;break;
case 8:sum=212;break;
case 9:sum=243;break;
case 10:sum=273;break;
case 11:sum=304;break;
case 12:sum=334;break;
}
if(temp=1)
{
if(month>2)
printf("It is the %dth day.\n",sum+day+1);
else
printf("It is the %dth day.\n",sum+day);
}
else
printf("It is the %dth day.\n",sum+day);
}
************************************************************************************
看过n 多次,思路因该没问题 啊
可就是输不出答案
而且对输入数据出错的if 判断似乎也没起到作用
哪位大哥能帮帮我看看
小弟感激不尽
[此贴子已经被作者于2007-9-13 16:16:01编辑过]