校园卡管理系统C语言.docx

上传人:b****8 文档编号:12924766 上传时间:2023-06-09 格式:DOCX 页数:14 大小:15.69KB
下载 相关 举报
校园卡管理系统C语言.docx_第1页
第1页 / 共14页
校园卡管理系统C语言.docx_第2页
第2页 / 共14页
校园卡管理系统C语言.docx_第3页
第3页 / 共14页
校园卡管理系统C语言.docx_第4页
第4页 / 共14页
校园卡管理系统C语言.docx_第5页
第5页 / 共14页
校园卡管理系统C语言.docx_第6页
第6页 / 共14页
校园卡管理系统C语言.docx_第7页
第7页 / 共14页
校园卡管理系统C语言.docx_第8页
第8页 / 共14页
校园卡管理系统C语言.docx_第9页
第9页 / 共14页
校园卡管理系统C语言.docx_第10页
第10页 / 共14页
校园卡管理系统C语言.docx_第11页
第11页 / 共14页
校园卡管理系统C语言.docx_第12页
第12页 / 共14页
校园卡管理系统C语言.docx_第13页
第13页 / 共14页
校园卡管理系统C语言.docx_第14页
第14页 / 共14页
亲,该文档总共14页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

校园卡管理系统C语言.docx

《校园卡管理系统C语言.docx》由会员分享,可在线阅读,更多相关《校园卡管理系统C语言.docx(14页珍藏版)》请在冰点文库上搜索。

校园卡管理系统C语言.docx

校园卡管理系统C语言

#include

#include

#include

#include

#include

structcard1/*校园卡的数据类型*/

{

intcardnum;

charstudentname[10];

intstudentclass;

intmoney;

charpassword[7];

}card[100];

voidman_system();/*完*/

voidstu_system();/*完*/

voiddelcard();/*完*/

voidaddcard();/*完*/

voidaddmoney();/*完*/

voidcheckmoney();/*完*/

/*guashi();*/

/*jiegua();*/

voidchangepassword();/*完*/

intpassword1();/*半完*/

intpassword2();/**/

inti1=0;

voidmain()/*主函数*/

{

intchoice;

do

{

printf("------------------------------------------\n");

printf("||\n");

printf("|Welcometoschoolcardsystem!

|\n\n");

printf("------------------------------------------\n");

printf("Pleasechoosesystem:

\n");

printf("1.managersystem\n");

printf("2.studentsystem\n");

printf("Pleaseint1-2:

");

scanf("%d",&choice);

switch(choice)

{

case1:

man_system();

break;

case2:

stu_system();

break;

default:

printf("Nothischoice!

");

break;

}

}

while

(1);

getch();

return;

}

voidman_system()/*管理端管理系统*/

{

intchoice;

intifright;

ifright=password1();

if(ifright==1)

{

while

(1)

{

printf("\n-----welcometomanagersystem-----\n");

printf("1:

Addnewcard\n2:

Delete\n3:

Addmoney\n4:

Checkmoney\n0:

Back\n");

printf("Pleaseint0-4:

");

scanf("%d",&choice);

switch(choice)

{

case1:

addcard();

break;

case2:

delcard();

break;

case3:

addmoney();

break;

case4:

checkmoney();

break;

case0:

return;

break;

default:

printf("Nothischoice!

\n");

break;

}

}

}

getch();

return;

}

voidstu_system()/*学生端管理系统*/

{

intchoice;

while

(1)

{

printf("\n-----Welcometostudentsystem-----\n");

printf("1:

Guashi\n2:

Jiegua\n3:

Changepassword\n4:

Checkmoney\n0:

Back\n");

printf("Pleaseint0-4:

");

scanf("%d",&choice);

switch(choice)

{

/*case1:

guashi();

break;

case2:

jiegua();

break;*/

case3:

changepassword();

break;

case4:

checkmoney();

break;

case0:

return;

break;

default:

printf("Can'tcametruenow!

\n");

break;

}

}

getch();

return;

}

voiddelcard()/*删除旧卡*/

{

FILE*fp,*fp2;

inti;

intcardnum;

charchoice;

fp=fopen("card.txt","r");

fp2=fopen("bookl.txt","w");

printf("Pleaseenterthenumberyouwanttodelete:

\n");

scanf("%d",&cardnum);

for(i=0;fread(&card[i],sizeof(structcard1),1,fp)!

=0;i++)

{

if(card[i].cardnum!

=cardnum)

{

fwrite(&card[i],sizeof(structcard1),1,fp2);

}

}

fclose(fp);

fclose(fp2);

printf("Doyoureallywanttodeletethisnumber(y/n):

\n\n");

scanf("%s",&choice);

if(choice=='y'||choice=='Y')

{

fp=fopen("card.txt","w");

fp2=fopen("bookl.txt","r");

for(i=0;fread(&card[i],sizeof(structcard1),1,fp2)!

=0;i++)

{

fwrite(&card[i],sizeof(structcard1),1,fp);

}

fclose(fp);

fclose(fp2);

fp2=fopen("bookl.txt","w");

fclose(fp2);

printf("Pressanykeytoreturn.\n");

getch();

return;

}

else

{

printf("Pressanykeytoreturn.\n");

getch();

return;

}

}

voidaddcard()/*添加新卡*/

{

FILE*fp;

intk;

fp=fopen("card.txt","a+");

printf("Enteryournumber:

\n");

flushall();

scanf("%d",&card[i1].cardnum);

flushall();

printf("Enteryourname:

\n");

scanf("%s",&card[i1].studentname);

flushall();

printf("Enteryourclassnumber:

\n");

scanf("%d",&card[i1].studentclass);

flushall();

card[i1].money=0;

printf("Pleasesetyourpasswordintheform*******:

");

for(k=0;k<7;k++)

{

card[i1].password[k]=getch();

printf("*");

}

getch();

printf("\n");

fwrite(&card[i1],sizeof(structcard1),1,fp);

fclose(fp);

printf("Pressanykeytoreturn.\n");

i1++;

getch();

}

intpassword1()/*管理端密码*/

{

charch[7],rig[7]={'1','2','3','4','5','6','7'};

inttime,i;

for(time=0;time<3;time++)

{

printf("Pleaseintyourpasswordintheform*******:

\n");

for(i=0;i<7;i++)

{

ch[i]=getch();

printf("*");

}

if(ch[0]==rig[0]&&ch[1]==rig[1]&&ch[2]==rig[2]&&ch[3]==rig[3]&&ch[4]==rig[4]&&ch[5]==rig[5]&&ch[6]==rig[6])

return1;

else

printf("Yourpasswordiswrong,pleaseintagain!

\n");

}

printf("Sorry,youcan'tentermanagersystem.\n");

return0;

}

voidaddmoney()/*存钱*/

{

FILE*fp,*fp2;

intadd,money,i,cardnum;

fopen("card.txt","r");

fopen("book.txt","w");

printf("Pleaseenterthecardnumber:

");

scanf("%d",&cardnum);

getch();

for(i=0;((card[i].cardnum)!

=cardnum);i++)

{

if(strcmp(card[i].cardnum,cardnum)==0)/*判断是否该卡*/

{

printf("Howmuchwouldyouliketoadd?

:

\n");

scanf("%d",&add);

card[i].money+=add;

fwrite(&card[i],sizeof(structcard1),1,fp2);

}

else

fwrite(&card[i],sizeof(structcard1),1,fp2);

}

fclose(fp);

fclose(fp2);

fp=open("card.txt","w");

fp2=open("book.txt","r");

for(i=0;fread(&card[i],sizeof(structcard1),1,fp2)!

=0;i++)

{

fwrite(&card[i],sizeof(structcard1),1,fp);

}

fclose(fp);

fclose(fp2);

printf("Pressanykeytoback\n");

getch();

return;

}

voidcheckmoney()

{

FILE*fp;

intcardnum,i;

fp=fopen("card.txt","r");

printf("Pleaseenterthenumberyouwanttocheck:

\n");

scanf("%d",&cardnum);

for(i=0;fread(&card[i],sizeof(structcard1),1,fp)!

=0;i++)

{

if(strcmp(cardnum,card[i].cardnum)==0)

{

printf("Themoneyofthiscardis%d",card[i].money);

return;

}

}

printf("Nothis!

\n");

fclose(fp);

return;

}

voidchangepassword()/*修改密码*/

{

FILE*fp,*fp2;

inti,k,cardnum,ifright;

fopen("card.txt","r");

fopen("book.txt","w");

printf("Pleaseentercardnumber:

");

scanf("%d",&cardnum);

for(i=0;fread(&card[i],sizeof(structcard1),1,fp)!

=0;i++)

{

if(strcmp(card[i].cardnum,cardnum)==0)/*判断是否该卡*/

{

ifright=password2();

if(ifright==0)

{

printf("\nYourpasswordiswrong!

\n");

return;

}

printf("Pleaseenteryournewpasswordintheformof*******:

\n");

for(k=0;k<7;k++)

{

card[i].password[k]=getch();

printf("*");

}

printf("\n");/*待改进*/

fwrite(&card[i],sizeof(structcard1),1,fp2);

continue;

}

fwrite(&card[i],sizeof(structcard1),1,fp2);

}

fclose(fp);

fclose(fp2);

fp=open("card.txt","w");

fp2=open("book.txt","r");

for(i=0;fread(&card[i],sizeof(structcard1),1,fp2)!

=0;i++)

{

fwrite(&card[i],sizeof(structcard1),1,fp);

}

fclose(fp);

fclose(fp2);

printf("Pressanykeytoback\n");

getch();

return;

}

intpassword2()/*学生密码*/

{

charpassword[7];

inti,k;

printf("Pleaseenteryourpasswordintheformof*******:

");

for(k=0;k<7;k++)

{

password[k]=getch();

printf("*");

}

for(k=0;k<7;k++)

{

if(password[k]!

=card[i].password[k])

return0;

}

getch();

return1;

}

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 临时分类 > 批量上传

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2