1067

//部分正确?
//

#include "stdafx.h"
#include
#include
#include

using namespace std;

int main()
{
    string password;
    unsigned n;
    cin >> password >> n;
    cin.ignore();       //getline()前必须清空回车符!

    string try_p;
    unsigned try_n = 0;
    getline(cin,try_p);
    while (try_p!="#")
    {
        try_n += 1;

        if (try_n > n)// 尝试次数超了没?超过次数后结束程序!
        {
            cout << "Account locked";
            break;
        }
        else//次数没超过才可以进行判断!
        {
            if (try_p == password)//密码正确吗?
            {
                cout << "Welcome in";
                break;
            }
            else
            {
                cout << "Wrong password: " << try_p;
            }
        }
        getline(cin, try_p);
        if (try_p != "#")
        {
            cout << endl;
        }

        
    }


    system("pause");
    return 0;
}

你可能感兴趣的:(1067)