28 lines
570 B
C++
28 lines
570 B
C++
#include <iostream>
|
|
|
|
using namespace std;
|
|
|
|
int main()
|
|
{
|
|
string name, pwd; // 用户名和密码
|
|
|
|
int n = 3; // 剩余尝试次数
|
|
while (n--)
|
|
{
|
|
cout << "请输入用户名: ";
|
|
cin >> name;
|
|
cout << "请输入密码: ";
|
|
cin >> pwd;
|
|
if (name == "fly" && pwd == "123")
|
|
{
|
|
cout << "登录成功" << endl;
|
|
break;
|
|
}
|
|
else if (n == 0)
|
|
break;
|
|
else
|
|
cout << "用户名或密码错误, 你还有" << n << "次机会" << endl;
|
|
}
|
|
|
|
return 0;
|
|
} |