年月日转换成天数
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
#include <iostream> using namespace std; int main(){ int n,y,r; int data[]={31,28,31,30,31,30,31,31,30,31,30,31};//下标对应月份,数值对应天数 while(cin>>n>>y>>r){ int sum; //将前面几个整月加上 for(int i=0;i<y-1;i++){ sum+=data[i]; } if((n%400==0||(n%4==0&&n%100!=0))&&y>2){ sum=sum+1+r; } else{ sum=sum+r; } cout<<sum<<endl; } return 0; }