如下面的:如果输入大于12或小于1,我进去了就不懂出来了,郁闷呐````。
例如我第一次输入错误,第二次输入正确,该怎样返回?
#include <iostream>
using namespace std;
void main()
{
cout <<"请输入要查询的月份:";
int n;
cin>>n;
if(n>12 || n<1)
{
for(int i=0;i<=3;i++)
{
if(n>12 || n<0)
cout <<"月份有小于1或大约12的吗?\n\n";
cout <<"请输入要查询的月份:";
cin>>n;
if(i>0)
{
cout <<"输入3次错误\n";
break;
}
}
}
else if(n==1)
cout <<"January\n";
else if(n==2)
cout <<"February\n";
else if(n==3)
cout <<"March\n";
else if(n==4)
cout <<"April\n";
else if(n==5)
cout <<"May\n";
else if(n==6)
cout <<"June\n";
else if(n==7)
cout <<"July\n";
else if(n==8)
cout <<"August\n";
else if(n==9)
cout <<"September\n";
else if(n==10)
cout <<"October\n";
else if(n==11)
cout <<"November\n";
else if(n==12)
cout <<" December\n";
}
又麻烦大家了