注意读取时的换行符用getchar吸收
第十个错误后直接输出锁定

#include<cstdio>
#include<string.h>

int main(){
    char mima[100],temp[10000];int N,flag=0;
    scanf("%s %d",mima,&N); 
    while(1){
        getchar();
        scanf("%[^\n]",temp);
        if(temp[0]=='#'&&temp[1]=='\0') break;
        flag++;
        if(strcmp(temp,mima)==0){
            printf("Welcome in\n");break;
        }else{
            printf("Wrong password: %s\n",temp);
            if(flag==N) {
                printf("Account locked\n");break;
            }
        }
    }
    return 0;
}

相关文章:

  • 2021-12-21
  • 2021-05-18
  • 2021-11-25
  • 2021-09-29
  • 2021-05-27
  • 2022-12-23
  • 2021-10-29
  • 2021-05-25
猜你喜欢
  • 2021-10-27
  • 2022-12-23
  • 2021-04-30
  • 2021-12-06
  • 2021-04-23
  • 2021-10-07
  • 2022-12-23
相关资源
相似解决方案