#include<iostream>
#include<string>
using namespace std;
int main()
{
string s1;
int cnt = 0; // 记录错误次数
while(1)
{
cout<<"请输入密码:"<<endl;
getline(cin,s1);
if(s1=="zzx")
{
cout<<"密码正确,欢迎使用"<<endl;
break;
}
else
{
cnt++;
cout<<"密码错误,请重新输入:"<<endl;
if(cnt >= 3)
{
cout<<"错误次数过多,程序退出!"<<endl;
break;
}
}
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: