#1167: 請問一下哪裡有錯?


chsh_mrsmile (熊)


#include <iostream>
using namespace std;
int main()
{
    int year;
    while(cin>>year)
    {
    if(year%4==0&&year%10!=0)
        cout <<"閏年"<<endl;
       
    else if(year%400==0)
        cout<<"閏年"<< endl;
       
    else
        cout<<"平年"<<endl;
       
    }

    return 0;
}

 

 

 

我輸入1977

是平年

可是為什麼是錯的?

#1168: Re:請問一下哪裡有錯?


magrady (元元)


#include
using namespace std;
int main()
{
    int year;
    while(cin>>year)
    {
    if(year%4==0&&year%100!=0)
        cout <<"閏年"<       
    else if(year%400==0)
        cout<<"閏年"<< endl;
       
    else
        cout<<"平年"<       
    }

    return 0;
}

 

 

 

我輸入1977

是平年

可是為什麼是錯的?