寫了個用戶登錄的小邏輯。
<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("不是迴文數!!!");
}
}
判斷是否爲迴文數,數組是自己定的,也可以隨機生成,鍵盤輸入。