判断某年某月某日是这一年的第几天 程序未报错 不知道为什么结果一直不对
#include <iostream>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
int main(int argc, char** argv) {
int year,month,day,a,b,c,d;
a==0;
b==0;
c==0;
d==0;
a==(month-1)*31+day+29;
b==(month-1)*30+day+29;
c==day;
d==31+day;
cout<<"Input year,month,day: "<<endl;
cin>>year>>month>>day;
if(year%4==0&&year%100!=0||year%100==0)
switch(month){
case 1:
cout<<"Days of year: "<<c;
break;
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
cout<<"Days of year: "<<a;
break;
case 4:
case 6:
case 9:
case 11:
cout<<"Days of year: "<<b;
break;
case 2:
cout<<"Days of year: "<<d;
break;
}
else
switch(month)
{
case 1:
cout<<"Days of year: "<<c;
break;
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
cout<<"Days of year: "<<a-1;
break;
case 4:
case 6:
case 9:
case 11:
cout<<"Days of year: "<<b-1;
break;
case 2:
cout<<"Days of year: "<<d;
break;
}
return 0;
}