题目:https://pintia.cn/problem-sets/994805260223102976/problems/994805266007048192

坑点在于不使用getline读取的话测试点2、5会过不了

代码

  1. #include<string>
  2. #include<cstdio>
  3. #include<iostream>
  4. using namespace std;
  5. int main(){
  6. string ans, input;
  7. int n, count = 0, flag = 0;
  8. cin>>ans>>n;
  9. getchar();
  10. getline(cin, input);
  11. while(input != "#" && count < n){
  12. count++;
  13. if(input == ans){
  14. printf("Welcome in\n");
  15. flag = 1;
  16. break;
  17. } else {
  18. cout<<"Wrong password: " + input<<endl;
  19. }
  20. getline(cin, input);
  21. }
  22. if(count == n && flag == 0) printf("Account locked\n");
  23. return 0;
  24. }