细节决定成败
such an easy problem that I didn't AC. WA 4 times.
Problem:
Judge if the (m, d) is a valid date, the year is 2010.
1. 2010 is not a leap year, so February has only 28 days.
2. Negative numbers must be considered.
#include <iostream> using namespace std; const int DAYS[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; int main() { int n; cin >> n; while (n--) { int m, d; cin >> m >> d; cout << ((m < 1 || m > 12 || d < 1 || d > DAYS[m]) ? "No" : "Maybe") << endl; } }