1067

//部分正确?
//

#include "stdafx.h"
#include<iostream>
#include<string>
#include<vector>

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;
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容