#includemain(){ int year,month,day,days,i,d; scanf("%d-%d-%d",&year,&month,&day); days=0; for(i=1;i<month;i++) { switch(i) { case 1:case 3:case 5:case 7:case 8:case 10:case 12:d=31;break; case 4:case 6:case 9:case 11:d=30break; case 2: if(year%4==0&&year%100!=0||year%400==0) d=29; else d=28; } days+=d; }printf("%d",days);}
你好!!!
改动一:case 11:
d=30; // 这里少了一个分号
改动二:days+=day; // 循环外面,这里加上输入的日期数
完整的代码:
#include<stdio.h>在这里可以:这里加可以吗
scanf("%d-%d-%d",&year,&month,&day);
days=day; // 赋值后,这里直接把输入的日期加上
你说的地方,要是加的话,再想想
完整的修改后代码:
#include<stdio.h>还是不行。。。
计算1号以后的就不行了