#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
// 定义一个字符数组用来存储密码
char password[1024] = { 0 };
int i = 0;
for (i = 0; i < 3; i++) {
printf("请输入您的密码!\n");
scanf_s("%s", password);
if (strcmp(password, "jhj52000") == 0) {
printf("登录成功!\n");
break;
}
}
if (i == 3) {
printf("登录失败!\n");
}
system("pause");
return 0;
}
模拟三次输入密码的场景,如果密码正确,提示“登录成功”,密码错误,可以重新输入,最多能输三次,如果三次均错则提示“登录失败”
猜你喜欢
转载自blog.csdn.net/qq_43508801/article/details/83754196
今日推荐
周排行