今年的第几天?
输入年、月、日,计算该天是本年的第几天。
输入描述:
包括三个整数年(1<=Y<=3000)、月(1<=M<=12)、日(1<=D<=31)。
输出描述:
输入可能有多组测试数据,对于每一组测试数据,
输出一个整数,代表Input中的年、月、日对应本年的第几天。
输入
1990 9 20
2000 5 1
输出
263
122
代码:
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
int months[13]={0,31,0,31,30,31,30,31,31,30,31,30,31};//月份天数
int main()
{
int year , month , data;
while(cin>>year>>month>>data)
{
int ans = 0;
if((year % 4 == 0 && year % 100 !=0)||(year % 400 ==0 ))//平年or闰年
months[2]=29;
else
months[2]=28;
for(int i = 1 ; i < month ; i++)
ans += months[i];
ans += data;
cout<<ans<<endl;
}
}
3738

被折叠的 条评论
为什么被折叠?



