校园卡管理系统-C语言_第1页
校园卡管理系统-C语言_第2页
校园卡管理系统-C语言_第3页
校园卡管理系统-C语言_第4页
已阅读5页,还剩5页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、#include#include#include#include#includestruct card1 /* 校园卡的数据类型*/int cardnum;char studentname10;int studentclass;int money;char password7;card100; TOC o 1-5 h z void man_system();/*完 */void stu_system();/*完 */void delcard();/*完 */void addcard();/*完 */void addmoney();/* 完 */void checkmoney();/* 完 */

2、*guashi();*/*jiegua();*/void changepassword();/* 完 */int password1();/* 半完 */int password2();/*/int i1=0;void main()/* 主函数 */int choice;doprintf(n);printf(|n);Welcome to schoolcard system!printf(|nn);printf(n);printf(Please choose system:n);printf( systemn);printf( systemn);printf(Please int 1-2:);s

3、canf(%d,&choice);switch(choice) man_system();break;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);moneyn4:Checkprintf(1:Addnewcard n2:Del

4、ete n3:Addmoneyn0:Backn);printf(Please int 0-4:);scanf(%d,&choice);switch(choice)addcard();break;delcard();break;addmoney();break;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 sy

5、stemn);passwordn4:Checkprintf(1:Guashin2:Jieguan3:Change moneyn0:Backn);printf(Please int 0-4:);scanf(%d,&choice);switch(choice)/*case 1:guashi();break;jiegua();break;*/changepassword();break;checkmoney();break;case 0:return;break;default:printf(Cant came true now!n); break;getch(); return;void delc

6、ard()/* 删除旧卡*/FILE *fp,*fp2;int i;int cardnum;char choice;fp=fopen(,r);fp2=fopen(,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

7、);printf(Do you really want to delete this number(y/n) :nn);scanf(%s,&choice);if(choice=y|choice=Y)fp=fopen(,w);fp2=fopen(,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(,w);fclose(fp2);printf(Press any key to retur

8、n.n);getch();return;elseprintf(Press any key to return.n);getch();chi=getch();return;void addcard()/* 添加新卡*/FILE *fp;int k;fp=fopen(,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 cl

9、assnumber: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 password1()

10、/* 管理端密码*/char ch7,rig7=1,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+)printf(*);if(ch0=rig0&ch1=rig1&ch2=rig2&ch3=rig3&ch4=rig4&c h5=rig5&ch6=rig6)return 1;elseprintf(Your password is wrong,please int again !n);printf(Sorry,you cant en

11、ter manager system.n);return 0;void addmoney()/* 存钱 */FILE *fp,*fp2;int add,money,i,cardnum;fopen(,r);fopen(,w);printf(Please enter the cardnumber:);scanf(%d,&cardnum);getch();for(i=0;(cardi.cardnum)!=cardnum);i+)if(strcmp(cardi.cardnum,cardnum)=0)/*判断是否该卡*/printf(How much would you like to add:n);s

12、canf(%d,&add);cardi.money+=add;fwrite(&cardi,sizeof(struct card1),1,fp2);elsefwrite(&cardi,sizeof(struct card1),1,fp2);fclose(fp);fclose(fp2);fp=open(,w);fp2=open(,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 a

13、ny key to backn);getch();return;void checkmoney()FILE *fp;int cardnum,i;fp=fopen(,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

14、;printf(No this !n);fclose(fp);return;void changepassword()/* 修改密码*/FILE *fp,*fp2;int i,k,cardnum,ifright;fopen(,r);fopen(,w);printf(Please enter cardnumber:);scanf(%d,&cardnum);for(i=0;fread(&cardi,sizeof(struct card1),1,fp)!=0;i+)if(strcmp(cardi.cardnum,cardnum)=0)/*判断是否该卡*/ifright=password2();if(

15、ifright=0)printf(nYour password is wrong!n);return;printf(Please enter your new password in the form of *:n);for(k=0;k7;k+)cardi.passwordk=getch();printf(*);printf(n);/*待改进 */fwrite(&cardi,sizeof(struct card1),1,fp2);continue;fwrite(&cardi,sizeof(struct card1),1,fp2);fclose(fp);fclose(fp2);fp=open(,w);fp2=open(,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 a

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论