mirror of
https://github.com/xlucn/PAT.git
synced 2026-10-03 00:23:15 +08:00
35 lines
698 B
C
35 lines
698 B
C
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
|
|
int main()
|
|
{
|
|
int N;
|
|
char c, correct[21], user[21];
|
|
|
|
scanf("%s %d", correct, &N);
|
|
while(getchar() != '\n');
|
|
while(N--)
|
|
{
|
|
scanf("%20[^\n]", user); /* avoid overflow */
|
|
c = ungetc(getchar(), stdin);
|
|
if(!strcmp(user, "#") && c == '\n')
|
|
{
|
|
break;
|
|
}
|
|
else if(!strcmp(correct, user) && c == '\n')
|
|
{
|
|
puts("Welcome in");
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
printf("Wrong password: %s", user);
|
|
while(putchar(getchar()) != '\n') ;
|
|
if(!N) puts("Account locked");
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|