版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/tonglin12138/article/details/78721716
老样子,直接上代码:
#include<stdio.h>
#include<string.h>
int main()
{
int land();
if (land() == 0)
{
printf("登录成功!!A麟真帅!!!\n");
}
else if (land() == -1)
{
printf("输入次数已经用尽,系统将自动退出!\n");
}
return 0;
}
int land()
{
int i = 3;
char ch[] = { "111" };
char input[20] = { 0 };
while (i)
{
printf("请输入你的登录密码:");
scanf("%s", input);
if (!strcmp(ch, input))
{
return 0;
}
else
{
i--;
printf("输入有误,剩余输入次数为%d\n",i);
}
}
if (i == 0)
{
return(-1);
}
return 0;
}
ok,登录成功信息的输出细节读者不用放在心上h…