//题目:输入一个年份,判断是否有闰年.
#include<iostream>
using namespace std;
int main()
{
int year;
bool IsLeapYear;
cout<<"Enter the year:/n"; //提醒用户输入
cout<<"if enter 0,exit the program./n";
cin>>year;
while (year)
{
IsLeapYear =((year % 4 == 0&& year % 100!=0)||(year%400==0));
if(IsLeapYear)
cout<<year<<"is a leap year/n/n/n"<<endl;
else
cout<<year<<"is not a leap year/n/n/n"<<endl;
cout<<"If you want to continue,please Enter the year:/n"; //请求用户再次输入
cout<<"if enter 0,esit the program./n";
cin>>year;
}
}
//此程序有一个问题:对于错误输入字母会造成死循环,如何解决?
//题目:输入一个年份,判断是否有闰年. 碰到一个问题```
最新推荐文章于 2024-02-15 16:31:08 发布