我不知道發生了什麼,但每次我把字母和特殊字符瘋狂地循環,我不知道如何糾正它。這是我從克勞德角度想到的。循環如果我輸入字母或特殊字符
#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
你能否請建議其他代碼轉到我不知道替代品 –