今年的第几天
题目描述
输入年、月、日,计算该天是本年的第几天。
输入描述:
包括三个整数年(1<=Y<=3000)、月(1<=M<=12)、日(1<=D<=31)。
输出描述:
输入可能有多组测试数据,对于每一组测试数据, 输出一个整数,代表Input中的年、月、日对应本年的第几天。
示例1
输出
复制263 122
1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 5 int Isrun(int x) 6 { 7 if(x%400==0||(x%4==0&&x%100!=0)) return 1; 8 else return 0; 9 } 10 int main() 11 { 12 int x,y,z; 13 while(cin>>x>>y>>z){ 14 int sum=z; 15 if(y>1){ 16 for(int i=1;i<y;i++){ 17 sum+=a[i]; 18 if(i==2&&Isrun(x)) sum++; 19 } 20 } 21 cout<<sum<<endl; 22 } 23 return 0; 24 }

浙公网安备 33010602011771号