题解 | #计算日期到天数转换#
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
#include <iostream> using namespace std; int main() { int a, b,c,day=0; int mouth[12]={31,28,31,30,31,30,31,31,30,31,30,31}; while (cin >> a >> b>>c) { // 注意 while 处理多个 case for (int i=0; i<b-1; i++) { day=day+mouth[i]; } } if (a%4==0&&a%100!=0) { day=day+1; } cout<<day+c; }