代码:
#include <stdio.h>
#include <string.h>
int main() {
char username[20];
char password[20];
int login_attempts = 0;
printf("Welcome to the login page!\n");
while (login_attempts < 3) {
printf("Please enter your username: ");
scanf("%s", username);
printf("Please enter your password: ");
scanf("%s", password);
if (strcmp(username, "admin") == 0 &&
strcmp(password, "password") == 0) {
printf("Login successful!\n");
break;
} else {
printf("Incorrect username or
password. Please try again.\n");
login_attempts++;
}
} if (login_attempts == 3) { printf("Too many login attempts. Please try again later.\n");
}
return 0;
}