标签:bre else iostream turn span code div bool mes
1 #include <iostream> 2 using namespace std; 3 int month[2][13] {{0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, 4 {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; 5 6 bool isLeap(int y) 7 { 8 return y % 400 == 0 || (y % 4 == 0 && y % 100 != 0); 9 } 10 11 int main() 12 { 13 ios::sync_with_stdio(false); 14 cin.tie(0); 15 int y, d; 16 cin >> y >> d; 17 int mon = 1; 18 int x = isLeap(y) ? 1 : 0; 19 20 for (int i = 1; i <= 12; i++) { 21 if (d > month[x][i]) { 22 d -= month[x][i]; 23 mon++; 24 } 25 else break; 26 } 27 cout << mon << endl; 28 cout << d << endl; 29 return 0; 30 }
标签:bre else iostream turn span code div bool mes
原文地址:https://www.cnblogs.com/AntonLiu/p/11165454.html