您的位置:首页 > 其它

PAT (Basic Level) 1067 试密码

2020-03-06 12:37 567 查看

题意

试密码,按要求输出。

思路

读入稍微注意一下,水~

代码

#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
string right;
int n;
cin >> right >> n;
cin.ignore(1);
string s;
int cnt = 0;
while (getline(cin, s)) {
if (s == "#") break;
if (s == right) {
cout << "Welcome in\n";
break;
}
cout << "Wrong password: " << s << '\n';
cnt++;
if (cnt == n) {
cout << "Account locked\n";
break;
}
}
return 0;
}

HINT

不定时更新更多题解,Basic Level 全部AC代码,详见 link ! ! !

  • 点赞
  • 收藏
  • 分享
  • 文章举报
xavier_cai 发布了107 篇原创文章 · 获赞 16 · 访问量 6203 私信 关注
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: