题解 | #今年的第几天?#
今年的第几天?
https://www.nowcoder.com/practice/ae7e58fe24b14d1386e13e7d70eaf04d
#include <iostream> using namespace std; bool is_run(int year){ if(year%4==0&&year%100!=0||year%400==0) return true; return false; } int month[]={0,31,28,31,30,31,30,31,31,30,31,30,12}; int main() { int y,m,d; while(cin>>y>>m>>d){ int res=0; if(is_run(y)){ month[2]++; for(int i=1;i<m;i++){ res+=month[i]; } res+=d; }else{ for(int i=1;i<m;i++){ res+=month[i]; } res+=d; } cout<<res<<endl; } return 0; } // 64 位输出请用 printf("%lld")