如何加入代码密码错误三次自动退出
1个回答
2017-02-09 · 知道合伙人互联网行家
关注
展开全部
#include <iostream>
using namespace std;
int main()
{
const char *password = "123654";
char Input_Password[10];
int count = 1;
cout << "请输入密码(三次机会):";
gets (Input_Password);
while (strcmp(password, Input_Password)!=0)
{
if (count < 3)
cout << "密码错误,请重新输入:";
if (count >= 3)
{
cout << "输入超过三次!\n";
break;
}
gets (Input_Password);
count++;
}
if (strcmp(password, Input_Password)==0)
cout << "恭喜,输入正确!\n";
return 0;
}
using namespace std;
int main()
{
const char *password = "123654";
char Input_Password[10];
int count = 1;
cout << "请输入密码(三次机会):";
gets (Input_Password);
while (strcmp(password, Input_Password)!=0)
{
if (count < 3)
cout << "密码错误,请重新输入:";
if (count >= 3)
{
cout << "输入超过三次!\n";
break;
}
gets (Input_Password);
count++;
}
if (strcmp(password, Input_Password)==0)
cout << "恭喜,输入正确!\n";
return 0;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询