void main()
創(chuàng)新互聯(lián)公司專注于網(wǎng)站建設(shè),為客戶提供成都網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)開發(fā)服務(wù),多年建網(wǎng)站服務(wù)經(jīng)驗(yàn),各類網(wǎng)站都可以開發(fā),成都品牌網(wǎng)站建設(shè),公司官網(wǎng),公司展示網(wǎng)站,網(wǎng)站設(shè)計(jì),建網(wǎng)站費(fèi)用,建網(wǎng)站多少錢,價(jià)格優(yōu)惠,收費(fèi)合理。
{
long kouling=12345; //假設(shè)你定義的口令是這個(gè);
int control;
long shuru;
for(control=0;control2;)
{
printf("請(qǐng)輸入口令并按回車(口令為整數(shù))");
scanf("%ld",shuru);
if(kouling==shuru)
{
printf("登陸成功!");
}
else
{
printf("登錄失敗,口令不正確!");
contrl++;
if(contrl==2)
{
printf("您已經(jīng)輸入錯(cuò)誤三次了,程序結(jié)束");
}
}
}
}
int?password;
scanf("%d\n",password);
if(password==123456){
printf("密碼正確");
}else{
if(password=123456){
printf("小于密碼");
}else{
printf("大于密碼");
}
}
我上學(xué)期做個(gè)這個(gè)程序,大部分相同.要的話我發(fā)給你,我的郵箱:
124460713@qq.com
#include
void
main()
{
int
n,password=123456,i=1;
while(1)
{
printf("輸入密碼:");
scanf("%d",n);
if(n==password)
printf("welcome
to
use
the
software\n");
else
{
if(i3)
printf("剩余的可輸入密碼的次數(shù)為:%d\n",3-i);
else
printf("password
error
!
you
can
not
use
the
software\n");
i++;
}
if(i=4||n==password)break;
}
}
這個(gè)是不需要用return的,簡明一點(diǎn),初學(xué)的應(yīng)該會(huì)
#include "stdio.h"
#include "stdlib.h"
#include "string.h"
int shoudsave=0; /* */
struct student
{
char num[10];/* 學(xué)號(hào) */
char name[20];
char sex[4];
int cgrade;
int mgrade;
int egrade;
int totle;
int ave;
char neartime[10];/* 最近更新時(shí)間 */
};
typedef struct node
{
struct student data;
struct node *next;
}Node,*Link;
void menu()
{
printf("********************************************************************************");
printf("\t1登記學(xué)生資料\t\t\t\t\t2刪除學(xué)生資料\n");
printf("\t3查詢學(xué)生資料\t\t\t\t\t4修改學(xué)生資料\n");
printf("\t5保存學(xué)生資料\t\t\t\t\t0退出系統(tǒng)\n");
printf("********************************************************************************\n");
}
void printstart()
{
printf("-----------------------------------------------------------------------\n");
}
void Wrong()
{
printf("\n=====提示:輸入錯(cuò)誤!\n");
}
void Nofind()
{
printf("\n=====提示:沒有找到該學(xué)生!\n");
}
void printc() /* 本函數(shù)用于輸出中文 */
{
printf(" 學(xué)號(hào)\t 姓名 性別 英語成績 數(shù)學(xué)成績 C語言成績 總分 平均分\n");
}
void printe(Node *p)/* 本函數(shù)用于輸出英文 */
{
printf("%-12s%s\t%s\t%d\t%d\t%d\t %d\t %d\n",p-data.num,p-data.name,p-data.sex,p-data.egrade,p-data.mgrade,p-data.cgrade,p-data.totle,p-data.ave);
}
Node* Locate(Link l,char findmess[],char nameornum[]) /* 該函數(shù)用于定位連表中符合要求的接點(diǎn),并返回該指針 */
{
Node *r;
if(strcmp(nameornum,"num")==0) /* 按學(xué)號(hào)查詢 */
{
r=l-next;
while(r!=NULL)
{
if(strcmp(r-data.num,findmess)==0)
return r;
r=r-next;
}
}
else if(strcmp(nameornum,"name")==0) /* 按姓名查詢 */
{
r=l-next;
while(r!=NULL)
{
if(strcmp(r-data.name,findmess)==0)
return r;
r=r-next;
}
}
return 0;
}
void Add(Link l) /* 增加學(xué)生 */
{
Node *p,*r,*s;
char num[10];
r=l;
s=l-next;
while(r-next!=NULL)
r=r-next; /* 將指針置于最末尾 */
while(1)
{
printf("請(qǐng)你輸入學(xué)號(hào)(以'0'返回上一級(jí)菜單:)");
scanf("%s",num);
if(strcmp(num,"0")==0)
break;
while(s)
{
if(strcmp(s-data.num,num)==0)
{
printf("=====提示:學(xué)號(hào)為'%s'的學(xué)生已經(jīng)存在,若要修改請(qǐng)你選擇'4 修改'!\n",num);
printstart();
printc();
printe(s);
printstart();
printf("\n");
return;
}
s=s-next;
}
p=(Node *)malloc(sizeof(Node));
strcpy(p-data.num,num);
printf("請(qǐng)你輸入姓名:");
scanf("%s",p-data.name);
getchar();
printf("請(qǐng)你輸入性別:");
scanf("%s",p-data.sex);
getchar();
printf("請(qǐng)你輸入c語言成績:");
scanf("%d",p-data.cgrade);
getchar();
printf("請(qǐng)你輸入數(shù)學(xué)成績:");
scanf("%d",p-data.mgrade);
getchar();
printf("請(qǐng)你輸入英語成績:");
scanf("%d",p-data.egrade);
getchar();
p-data.totle=p-data.egrade+p-data.cgrade+p-data.mgrade;
p-data.ave=p-data.totle / 3;
/* 信息輸入已經(jīng)完成 */
p-next=NULL;
r-next=p;
r=p;
shoudsave=1;
}
}
void Qur(Link l) /* 查詢學(xué)生 */
{
int sel;
char findmess[20];
Node *p;
if(!l-next)
{
printf("\n=====提示:沒有資料可以查詢!\n");
return;
}
printf("\n=====1按學(xué)號(hào)查找\n=====2按姓名查找\n");
scanf("%d",sel);
if(sel==1)/* 學(xué)號(hào) */
{
printf("請(qǐng)你輸入要查找的學(xué)號(hào):");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
printf("\t\t\t\t查找結(jié)果\n");
printstart();
printc();
printe(p);
printstart();
}
else
Nofind();
}
else if(sel==2) /* 姓名 */
{
printf("請(qǐng)你輸入要查找的姓名:");
scanf("%s",findmess);
p=Locate(l,findmess,"name");
if(p)
{
printf("\t\t\t\t查找結(jié)果\n");
printstart();
printc();
printe(p);
printstart();
}
else
Nofind();
}
else
Wrong();
}
void Del(Link l) /* 刪除 */
{
int sel;
Node *p,*r;
char findmess[20];
if(!l-next)
{
printf("\n=====提示:沒有資料可以刪除!\n");
return;
}
printf("\n=====1按學(xué)號(hào)刪除\n=====2按姓名刪除\n");
scanf("%d",sel);
if(sel==1)
{
printf("請(qǐng)你輸入要?jiǎng)h除的學(xué)號(hào):");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
r=l;
while(r-next!=p)
r=r-next;
r-next=p-next;
free(p);
printf("\n=====提示:該學(xué)生已經(jīng)成功刪除!\n");
shoudsave=1;
}
else
Nofind();
}
else if(sel==2)
{
printf("請(qǐng)你輸入要?jiǎng)h除的姓名:");
scanf("%s",findmess);
p=Locate(l,findmess,"name");
if(p)
{
r=l;
while(r-next!=p)
r=r-next;
r-next=p-next;
free(p);
printf("\n=====提示:該學(xué)生已經(jīng)成功刪除!\n");
shoudsave=1;
}
else
Nofind();
}
else
Wrong();
}
void Modify(Link l)
{
Node *p;
char findmess[20];
if(!l-next)
{
printf("\n=====提示:沒有資料可以修改!\n");
return;
}
printf("請(qǐng)你輸入要修改的學(xué)生學(xué)號(hào):");
scanf("%s",findmess);
p=Locate(l,findmess,"num");
if(p)
{
printf("請(qǐng)你輸入新學(xué)號(hào)(原來是%s):",p-data.num);
scanf("%s",p-data.num);
printf("請(qǐng)你輸入新姓名(原來是%s):",p-data.name);
scanf("%s",p-data.name);
getchar();
printf("請(qǐng)你輸入新性別(原來是%s):",p-data.sex);
scanf("%s",p-data.sex);
printf("請(qǐng)你輸入新的c語言成績(原來是%d分):",p-data.cgrade);
scanf("%d",p-data.cgrade);
getchar();
printf("請(qǐng)你輸入新的數(shù)學(xué)成績(原來是%d分):",p-data.mgrade);
scanf("%d",p-data.mgrade);
getchar();
printf("請(qǐng)你輸入新的英語成績(原來是%d分):",p-data.egrade);
scanf("%d",p-data.egrade);
p-data.totle=p-data.egrade+p-data.cgrade+p-data.mgrade;
p-data.ave=p-data.totle/3;
printf("\n=====提示:資料修改成功!\n");
shoudsave=1;
}
else
Nofind();
}
void Disp(Link l)
{
int count=0;
Node *p;
p=l-next;
if(!p)
{
printf("\n=====提示:沒有資料可以顯示!\n");
return;
}
printf("\t\t\t\t顯示結(jié)果\n");
printstart();
printc();
printf("\n");
while(p)
{
printe(p);
p=p-next;
}
printstart();
printf("\n");
}
void Tongji(Link l)
{
Node *pm,*pe,*pc,*pt,*pa; /* 用于指向分?jǐn)?shù)最高的接點(diǎn) */
Node *r=l-next;
if(!r)
{
printf("\n=====提示:沒有資料可以統(tǒng)計(jì)!\n");
return ;
}
pm=pe=pc=pt=pa=r;
while(r!=NULL)
{
if(r-data.cgrade=pc-data.cgrade)
pc=r;
if(r-data.mgrade=pm-data.mgrade)
pm=r;
if(r-data.egrade=pe-data.egrade)
pe=r;
if(r-data.totle=pt-data.totle)
pt=r;
if(r-data.ave=pa-data.ave)
pa=r;
r=r-next;
}
printf("------------------------------統(tǒng)計(jì)結(jié)果--------------------------------\n");
printf("總分最高者:\t%s %d分\n",pt-data.name,pt-data.totle);
printf("平均分最高者:\t%s %d分\n",pa-data.name,pa-data.ave);
printf("英語最高者:\t%s %d分\n",pe-data.name,pe-data.egrade);
printf("數(shù)學(xué)最高者:\t%s %d分\n",pm-data.name,pm-data.mgrade);
printf("c語言最高者:\t%s %d分\n",pc-data.name,pc-data.cgrade);
printstart();
}
void Sort(Link l)
{
Link ll;
Node *p,*rr,*s;
ll=(Link)malloc(sizeof(Node)); /* 用于做新的連表 */
ll-next=NULL;
if(l-next==NULL)
{
printf("\n=====提示:沒有資料可以排序!\n");
return ;
}
p=l-next;
while(p)
{
s=(Node*)malloc(sizeof(Node)); /* 新建接點(diǎn)用于保存信息 */
s-data=p-data;
s-next=NULL;
rr=ll;
while(rr-next!=NULL rr-next-data.totle=p-data.totle)
rr=rr-next;
if(rr-next==NULL)
rr-next=s;
else
{
s-next=rr-next;
rr-next=s;
}
p=p-next;
}
free(l);
l-next=ll-next;
printf("\n=====提示:排序已經(jīng)完成!\n");
}
void Save(Link l)
{
FILE* fp;
Node *p;
int flag=1,count=0;
fp=fopen("c:\\student","wb");
if(fp==NULL)
{
printf("\n=====提示:重新打開文件時(shí)發(fā)生錯(cuò)誤!\n");
exit(1);
}
p=l-next;
while(p)
{
if(fwrite(p,sizeof(Node),1,fp)==1)
{
p=p-next;
count++;
}
else
{
flag=0;
break;
}
}
if(flag)
{
printf("\n=====提示:文件保存成功.(有%d條記錄已經(jīng)保存.)\n",count);
shoudsave=0;
}
fclose(fp);
}
void main()
{
Link l;/* 連表 */
FILE *fp; /* 文件指針 */
int sel;
char ch;
char jian;
int count=0;
Node *p,*r;
printf("\t\t\t\t學(xué)生成績管理系統(tǒng)\n\t\t\t\t-------福建農(nóng)業(yè)職業(yè)學(xué)院計(jì)應(yīng)0501 黃歡(32號(hào))\n");
l=(Node*)malloc(sizeof(Node));
l-next=NULL;
r=l;
fp=fopen("C:\\student","rb");
if(fp==NULL)
{
printf("\n=====提示:文件還不存在,是否創(chuàng)建?(y/n)\n");
scanf("%c",jian);
if(jian=='y'||jian=='Y')
fp=fopen("C:\\student","wb");
else
exit(0);
}
printf("\n=====提示:文件已經(jīng)打開,正在導(dǎo)入記錄......\n");
while(!feof(fp))
{
p=(Node*)malloc(sizeof(Node));
if(fread(p,sizeof(Node),1,fp)) /* 將文件的內(nèi)容放入接點(diǎn)中 */
{
p-next=NULL;
r-next=p;
r=p; /* 將該接點(diǎn)掛入連中 */
count++;
}
}
fclose(fp); /* 關(guān)閉文件 */
printf("\n=====提示:記錄導(dǎo)入完畢,共導(dǎo)入%d條記錄.\n",count);
while(1)
{
menu();
printf("請(qǐng)你選擇操作:");
scanf("%d",sel);
if(sel==0)
{
if(shoudsave==1)
{ getchar();
printf("\n=====提示:資料已經(jīng)改動(dòng),是否將改動(dòng)保存到文件中(y/n)?\n");
scanf("%c",ch);
if(ch=='y'||ch=='Y')
Save(l);
}
printf("\n=====提示:你已經(jīng)退出系統(tǒng),再見!\n");
break;
}
switch(sel)
{
case 1:Add(l);break; /* 增加學(xué)生 */
case 2:Del(l);break;/* 刪除學(xué)生 */
case 3:Qur(l);break;/* 查詢學(xué)生 */
case 4:Modify(l);break;/* 修改學(xué)生 */
case 5:Save(l);break;/* 保存學(xué)生 */
case 9:printf("\t\t\t==========幫助信息==========\n");break;
default: Wrong();getchar();break;
}
}
}
/* */
再給你個(gè)網(wǎng)站 你可能會(huì)需要他的
#include stdio.h
#include string.h
typedef struct
{
long number; //用戶編號(hào) 6位
char name[20]; //用戶名
char password[8]; //用戶密碼
int power; //權(quán)限判斷 1 為管理員2為普通用戶
} user;
user yh[100]={100000,"gavin","gavine",1,100001,"wnag","wangf",2};
int length = 2;
int checkuser(long num, const char *nm, const char *pwd)
{
int i;
for (i = 0; i length; ++i)
{
if (yh[i].number == num !strcmp(yh[i].name, nm) !strcmp(yh[i].password, pwd))
{
if (1==yh[i].power)
return 1;
else
return 2;
}
}
}
void main()
{
printf("%d\n", checkuser(100000, "gavin", "gavine"));
}
本文名稱:c語言口令驗(yàn)證函數(shù)怎么用 c語言驗(yàn)證碼代碼
文章出自:http://jinyejixie.com/article40/dosceho.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航、全網(wǎng)營銷推廣、App設(shè)計(jì)、做網(wǎng)站、網(wǎng)站建設(shè)、品牌網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)