为什么运行就错误呢? 编译没有错误啊?
我遍了个程序,输入年月日,计算这个是一年中的第几天?程序代码:
#include"stdio.h" #include"math.h" void main() { unsigned year,month,day,sum,leap; printf("请输入年,月,日:\n"); scanf("%u,%u,%u",year,month,day); switch(month) { case 1: sum=0; break; case 2: sum=31; break; case 3: sum=31+28; break; case 4: sum=31+28+31; break; case 5: sum=31+28+31+30; break; case 6: sum=31+28+31+30+31; break; case 7: sum=31+28+31+30+31+30; break; case 8: sum=31+28+31+30+31+30+31; break; case 9: sum=31+28+31+30+31+30+31+31; break; case 10: sum=31+28+31+30+31+30+31+31+30; break; case 11: sum=31+28+31+30+31+30+31+31+30+31; break; case 12: sum=31+28+31+30+31+30+31+31+30+31+30; break; default: printf("Dataerror\n"); } sum=sum+day; if(year%4==0) { leap=1; } else { leap=0; } if(leap==1&&month>2) { ++sum; } printf("第%u天\n",sum); }