PAT basic 1067

来源:互联网 发布:罗莱蚕丝被 知乎 编辑:程序博客网 时间:2024/05/30 07:13
#include <iostream>using namespace std;int main() {    string password, temp;    int n, cnt = 0;    cin >> password >> n;    getchar();    while(1) {        getline(cin, temp);        if (temp == "#") break;        cnt++;        if (cnt <= n && temp == password) {            cout << "Welcome in";            break;        } else if (cnt <= n && temp != password) {            cout << "Wrong password: " << temp << endl;            if (cnt == n) {                cout << "Account locked";                break;            }        }    }    return 0;}