#include <iostream>
#include <cstdlib>
using namespace std;
int main()
{
int Y;
while(true)
{cin>>Y;
if((Y%4==0&&Y%100!=0)||(Y%400==0))
{
cout<<"閏年"<<endl;
}
else
{
cout<<"平年"<<endl;
}}
}
已經用過while跟do while
不管怎樣都TLE
#include
#include
using namespace std;
int main()
{
int Y;
while(true)
{cin>>Y;
if((Y%4==0&&Y%100!=0)||(Y%400==0))
{
cout<<"閏年"<<endl;
}
else
{
cout<<"平年"<<endl;
}}
}
已經用過while跟do while
不管怎樣都TLE
你這是無窮迴圈
把while(true)改成while(cin>>Y)就OK了