#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main()
{
char pwd[10] = { 0 };
int i = 0;
for (i = 0; i < 3;i++)
{
printf("请输入字符串密码:\n");
scanf("%s", pwd);
if (strcmp(pwd,"abcd")==0)
{
printf("登陆成功!\n");
break;
}
else
{
printf("登录失败!\n");
}
}
if (i == 3)
{
printf("三次密码错误,退出程序!");
}
system("pause");
return 0;
}
编写代码实现,模拟用户登录情景,并且只能登录三次。 只允许输入三次密码,如果密码正确则提示登录成,如果三次均输入错误,则退出程序。
最新推荐文章于 2023-01-11 21:29:42 发布