工作生活

PAT 1067 试密码 (20 分)

2019-07-02  本文已影响0人  昭明ZMing
#include<iostream>
#include<string>
using namespace std;
int main() {
    string password,str;
    int n, count = 0;
    cin >> password >> n;
  getchar();//
    while (n--) {
        getline(cin, str);
        if (str == "#")  //接收到#,退出程序
            return 0;
        else if (str == password) {   //密码正确,退出程序
            cout << "Welcome in" << endl;
            return 0;
        }
        else
                cout << "Wrong password: " << str << endl;
    }
    cout << "Account locked" << endl;
    return 0;
}
上一篇 下一篇

猜你喜欢

热点阅读