
用C语言设计取款系统循环版,密码错误三次就退出程序。
展开全部
#include<iostream>
#include <string>
using namespace std;
int Login();
void main()
{
int count=1;
for(;!Login()&&count<3;count++);
if (count>2)
{
cout<<"输入密码错误超过3次,程序将退出"<<endl;
}
else
{
cout<<"登陆成功,可以取款了"<<endl;
}
}
int Login()
{
string pwd;
cout<<"请输入密码:";
cin>>pwd;
if (pwd=="123456")
{
return 1;
}
return 0;
}
#include <string>
using namespace std;
int Login();
void main()
{
int count=1;
for(;!Login()&&count<3;count++);
if (count>2)
{
cout<<"输入密码错误超过3次,程序将退出"<<endl;
}
else
{
cout<<"登陆成功,可以取款了"<<endl;
}
}
int Login()
{
string pwd;
cout<<"请输入密码:";
cin>>pwd;
if (pwd=="123456")
{
return 1;
}
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询