当用户输入用户名为:123和密码为:456时登录成功 否则重新登录。并且限制次数为三次,三次之后无权限登录。
第1个回答 2010-08-10
#include<stdio.h>
#include<string.h>
int main(void)
{
char name[] = "123";
char psd[] = "456";
char inname[32],inpsd[32];
int i = 1;
do
{
printf("please input your name:");
gets(inname);
printf("please input the password:");
gets(inpsd);
if(!(strcmp(name,inname) || strcmp(psd,inpsd)))
{
printf("login succeed\n");
return 0;
}
i++;
}while(i <= 3);
printf("you can't get into the system after the three times wrong name and password!\n");
return 0;
}本回答被提问者采纳
#include<string.h>
int main(void)
{
char name[] = "123";
char psd[] = "456";
char inname[32],inpsd[32];
int i = 1;
do
{
printf("please input your name:");
gets(inname);
printf("please input the password:");
gets(inpsd);
if(!(strcmp(name,inname) || strcmp(psd,inpsd)))
{
printf("login succeed\n");
return 0;
}
i++;
}while(i <= 3);
printf("you can't get into the system after the three times wrong name and password!\n");
return 0;
}本回答被提问者采纳