写了个用户登录的小逻辑。
<pre name="code" class="cpp">int count(int c)
{
return c;
}
//验证用户名与密码
int password()
{
char s3[20];
char s4[20];
int c=0;
printf("请输入用户名:");
gets(s3);
if(strcmp("jerehdu", s3)==0)
{
pass:
printf("请输入密码:");
gets(s4);
if(strcmp("jereh123", s4)==0)
{
printf("用户名密码正确!!!====\n");
c=1;
count(c);
return c;
}else
{
printf("密码错误!!!\n");
goto pass;
}
}else
{
printf("用户名错误!!!\n");
}
return 0;
}
main里面的函数调用
int c=0;
//登录验证
while(count(c)==0)
{
c=password();
}
void redata()
{
int a[10]={5,4,3,2,1,1,8,3,4,5};
int *star,*end;
int flag=0;
star=&a[0];//star=a;
end=&a[9];
for(;star<=end;star++,end--)
{
if(*star==*end)
{
}else
{
flag=1;
break;
}
}
if(flag==0)
{
printf("是回文数!!!");
}else
{
printf("不是回文数!!!");
}
}
判断是否为回文数,数组是自己定的,也可以随机生成,键盘输入。