资源预览内容
第1页 / 共8页
第2页 / 共8页
第3页 / 共8页
第4页 / 共8页
第5页 / 共8页
第6页 / 共8页
第7页 / 共8页
第8页 / 共8页
亲,该文档总共8页全部预览完了,如果喜欢就下载吧!
资源描述
#include #include #include #include #include struct card1 /*校园卡的数据类型*/ int cardnum;char studentname10; int studentclass; int money;char password7; card100;void man_system();/* 完*/ void stu_system();/* 芫*/ void delcard();/* 完*/ void addcard();/* 完*/ void addmoney();/* 完*/ void checkmoney();/* 完 */ /*guashi();*/ /*jiegua();*/ void changepassword();/* 完*/ int password1();/* 半完 */ int password2();/*/ int i1=0;void main()/* 主函数*/int choice;doprintf(n);|n);|nn);printf(|printf(|Welcome to schoolcard system!printf(n);printf(Please choose system:n); printf(1.manager systemn); printf(2.student systemn); printf(Please int 1-2:); scanf(%d,&choice); switch(choice)case 1:man_system();break;case 2:stu_system();break;default:printf(No this choice!); break;while(1);getch();return;void man_system()/*管理端管理系统*/int choice;int ifright;ifright=password1();if(ifright=1)while(1)printf(nwelcome to manager systemn);printf(1:Add newcard n2:Delete n3:Add moneyn4:Check moneyn0:Backn); printf(Please int 0-4:);scanf(%d,&choice);switch(choice)case 1:addcard();break;case 2:delcard();break;case 3:addmoney();break;case 4:checkmoney();break;case 0:return;break;default:printf(No this choice!n);break;getch();return;void stu_system()/*学生端管理系统*/int choice;while(1)printf(nWelcome to student systemn);printf(1:Guashin2:Jieguan3:Change passwordn4:Check moneyn0:Backn); printf(Please int 0-4:);scanf(%d,&choice);switch(choice)/*case 1: guashi();break;case 2:jiegua();break;*/case 3:changepassword();break;case 4:checkmoney();break;case 0:return;break;default:printf(Cant came true now!n);break;getch();return;void delcard()/* 删除旧卡 */int i;int cardnum;char choice;fp=fopen(card.txt,r);fp2=fopen(bookl.txt,w);printf(Please enter the number you want to delete:n); scanf(%d,&cardnum);for(i=0;fread(&cardi,sizeof(struct card1),1,fp)!=0;i+) if(cardi.cardnum!=cardnum) fwrite(&cardi,sizeof(struct card1),1,fp2);fclose(fp);fclose(fp2);printf(Do you really want to delete this number(y/n) :nn); scanf(%s,&choice);if(choice=y|choice=Y)fp=fopen(card.txt,w);fp2=fopen(bookl.txt,r); for(i=0;fread(&cardi,sizeof(struct card1),1,fp2)!=0;i+) fwrite(&cardi,sizeof(struct card1),1,fp);fclose(fp); fclose(fp2);fp2=fopen(bookl.txt,w); fclose(fp2);printf(Press any key to return.n); getch();return;elseprintf(Press any key to return.n);getch(); return;int k;fp=fopen(card.txt,a+); printf(Enter your number:n);flushall();scanf(%d,&cardi1.cardnum); flushall();printf(Enter your name:n); scanf(%s,&cardi1.studentname); flushall();printf(Enter your classnumber:n); scanf(%d,&cardi1.studentclass); flushall();cardi1.money=0;printf(Pleas e set your password in the form *:); for(k=0;k7;k+) cardi1.passwordk=getch(); printf(*);getch();printf(n); fwrite(&cardi1,sizeof(struct card1),1,fp); fclose(fp);printf(Press any key to return.n);i1+; getch();int passwordl()/* 管理端密码 */char ch7,rig7=l,2,3,4,5,6,7;int time,i;for(time=0;time3;time+)printf(Please int your password in the form *:n);for(i=0;i7;i+) chi=getch();printf(*);if(ch0=rig0&chl=rigl&ch2=rig2&ch3=rig3&ch4=rig4&ch5= rig5&ch6=rig6)return l;elseprintf(Your password is wrong,please int again !n); printf(Sorry,you cant enter manager system.n); return 0;void addmoney()/* 存钱 */FILE *fp,*fp2;int add,money,i,cardnum;fopen(card.txt,r); fopen(book.txt,w); printf(Please enter the cardnumber:); scanf(%d,&cardnum); getch();for(i=0;(cardi.cardnum)!=cardnum);i+) if(strcmp(cardi.cardnum,cardnum)=O)/*判 断是否该卡 */ printf(How much would you like to add?:n); scanf(%d,&add);cardi.money+=add; fwrite(&cardi,sizeof(struct card1),1,fp2);else fwrite(&cardi,sizeof(struct card1),1,fp2);fclose(fp);fclose(fp2);fp=open(card.txt,w); fp2=open(book.txt,r); for(i=0;fread(&cardi,sizeof(struct card1),1,fp2)!=0;i+) fwrite(&cardi,sizeof(struct card1),1,fp);fclose(fp);fclose(fp2);printf(Press any key to backn);getch();return;int cardnum,i; fp=fopen(card.txt,r); printf(Please enter the number you want to check:n); scanf(%d,&cardnum);for(i=0;fread(&cardi,sizeof(struct card1),1,fp)!=0;i+) if(strcmp(cardnum,cardi.cardnum)=0)printf(The money of this card is %d,cardi.money); return;printf(No this !n);fclose(fp);return;void changepassword()/* 修改密码*/FILE *fp,*fp2;int i,k,cardn
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号