#include
using namespace std;
int main()
{
int i;
cout << "输入年份" <<endl ;
cin >> i;
if (i%400==0||(i%4==0&&i%100!=0)){
cout <<"是闰年"<<endl;
}
else{
cout <<"不是闰年"<<endl;
}
return 0;
}
这是我写的一直错,哪位能帮帮忙
改成 if( i%4==0 && i%100 !=0 || i%400 == 0)
你的代码也是没有问题的啊,具体出什么错误呢?
代码:
#include <iostream>
using namespace std;
int main()
{
int i;
cout << "输入年份" << endl;
cin >> i;
if (i % 4 == 0 && i % 100 != 0 || i%400==0) {
cout << "是闰年" << endl;
}
else {
cout << "不是闰年" << endl;
}
return 0;
}
2020年不是闰年吗?有什么错的?