#11080: 請問,是否需定義年份為正整數?


eli00713 (蘭寶)


這個程式碼雖然通過了,不過看論壇上有帖子提到需要考慮年份為正整數,

想請問,若要加年份大於0得條件的話,可以怎樣寫呢?

初學者,想了一陣子還是沒頭緒,想請諸位大大協助,

感謝 ~ 

-----------------------------------------------------------------------------------

#include <iostream>

using namespace std;

 

int main() {

    

    int n;

    

    while (cin >> n){

        

        if (((n%4 == 0) && (n%100 != 0)) || (n % 400 == 0)) {

            cout << "閏年" << endl;

        }

        

        else {

            cout << "平年" << endl;

        }

    }

    

    return 0;

}