我不知道发生了什么,但每次我把字母和特殊字符疯狂地循环,我不知道如何纠正它。这是我从克劳德角度想到的。循环如果我输入字母或特殊字符
#include<iostream>
using namespace std;
int main()
{
int a,b;
Claude:
{
cout<<"Please Enter Your Pin: ";
cin>>a;
cout<<endl;
system("cls");
cin.get();
}
if(a==1234)
{ Josh:
cout<<"Choose An Option: "<<endl;
cout<<"1: Withdraw 2: Check Balance";
cout<<endl;
cout<<"3: Deposit 4: Exit";
cout<<endl;
cout<<"Enter Here: ";
cin>>b;
system("cls");
}
else
{
cout<<"Incorrect Pin, Please Try Again"<<endl;
cout<<endl;
cout<<"Press Any Key To Continue "<<endl;
system("pause>nul");
system("cls");
goto Claude;
}
if(b==1)
{
cout<<"How Much: ";
}
else if (b==2)
{
cout<<"2000.00";
}
else if(b==3)
{
cout<<"Nothing To Withdraw";
}
else if(b==4)
{
cout<<"test";
}
else
{
cout<<"Please Enter Valid Input, Press Any Key To Continue ";
cin.get();
system("cls");
goto Josh;
}
return 0;
}
该代码工作正常,工作正常。请在您自己的开发C++中查找结果。
删除不需要的,使你的代码更不可读 –
建议额外的括号:不使用goto语句(http://stackoverflow.com/questions/3517726/what-is-wrong-with-使用goto) – CIsForCookies
你能否请建议其他代码转到我不知道替代品 –