zoukankan      html  css  js  c++  java
  • 细节决定成败

    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;
    	}
    }
    
    
  • 相关阅读:
    P1541
    P1004
    P1006
    高精度
    数组
    递归
    顺序结构
    循环结构
    变量
    分支结构
  • 原文地址:https://www.cnblogs.com/ajeyone/p/1834487.html
Copyright © 2011-2022 走看看