#define _CRT_SECURE_NO_WARNINGS 1
#include <string.h>
#include <stdio.h>
int main()
{
char accounts[10] = { 0 };
char password[10] = { 0 };
int i = 0;
printf("请输入账号:>");
scanf("%s", &accounts);//输入账号
while (i < 3)
{
if (strcmp(accounts, "123456") == 0) || strcmp(accounts, "123") == 0 || strcmp(accounts, "456") == 0)//假定三个账号
{
printf("登记库中存在\n");
break;
}
else
{
i++;
printf("账号不存在\n");
printf("请输入账号:>");
scanf("%s", &accounts);//重新输入
}
}
for (i = 1; i <= 3; i++)
{
printf("请输入密码:>");
scanf("%s", &password);
if ((strcmp(password, "YG123456") == 0))//==不能用来比较两个字符串是否相等,应该使用一个库函数-strcmp
{
if(strcmp(accounts, "123456") == 0)
{
printf("登陆成功\n");
printf("欢迎进入‘bit’\n");
break;
}
else
{
printf("账号不在登记库中,不予登录\n");
printf("请输入账号:>");
scanf("%s", &accounts);
}
if (i == 3)
{
printf("三次均错误,账号已冻结\n");
}
}
return 0;
}
账号密码登录测试
最新推荐文章于 2023-08-04 13:34:19 发布