汽车租赁管理系统———c语言课程设计(10页).doc
-#include<stdio.h> #include<string.h> #include<stdlib.h>#include<conio.h> struct member int cardnum; char lendcar10; member5; struct car int carnum; char carname20; float carprice; char carcreat20; int turefalse; car5; struct card int cardnum; char sex5; char membersname20; long int memberstel; card5; findcar() char carname10; int i; printf("nn请输入你要查找的车型:n"); scanf("%s",carname); for(i=0;i<5;i+) while(strcmp(carname,cari.carname)=0) if(cari.turefalse=1) printf(" 编号 车型 品牌n %d %s %s n",cari.carnum,cari.carname,cari.carcreat); printf("nn"); printf("-此车现在无人租用n."); printf("-按任意键返回n"); break; else printf("nn-这辆车已经有人借出n");break; return 0; findcar1() char carcreat10; int i; printf("nn请输入你要查找的品牌:n"); scanf("%s",carcreat); for(i=0;i<5;i+) while(strcmp(carcreat,cari.carcreat)=0) if(cari.turefalse=1) printf(" 编号 车型 品牌n %d %s %s n",cari.carnum,cari.carname,cari.carcreat); printf("nn"); printf("-此车现在无人租用n."); printf("-按任意键返回nn"); break; else printf("nn-这辆车已经有人借出!n");printf("-按任意键返回nn"); break; return 0; chacar() char ch5; do printf("nn 1: 按车型查找 n"); printf(" 2: 按品牌查找 n"); printf(" 0: 返回 n"); printf(" 请输入02:n"); ch5=getch(); switch(ch5) case '1':findcar();getch();break; case '2':findcar1();getch();break; case '0':break; default:printf("-无此操作!n");getch();break; while(ch5!='0'); return 0; lendcar() int i,n; int cardnum; printf("nn请输入卡号 :n"); scanf("%d",&cardnum); for(i=0;i<5;i+) if(cardi.cardnum=cardnum) n=i; printf("n车型:"); scanf("%s",membern.lendcar); for(i=0;i<5;i+) if(strcmp(cari.carname,membern.lendcar)=0) if(cari.turefalse=0) printf("-对不起,此车已被租出,请重新选择n"); getch();return 0; else membern.cardnum=cardnum; for(i=0;i<5;i+) if(strcmp(cari.carname,membern.lendcar)=0) cari.turefalse=0; continue; printf("nn-操作成功,请及时提车."); printf("n-按任意键返回.n"); getch(); return 0; printf("nn-错误操作."); printf("n-按任意键返回.n"); getch(); return 0; printf("nn-你的卡号不存在,请申请新卡.n"); printf("n-按任意键返回.n"); getch(); return 0; huancar() int i,n; int cardnum; char lendcar10; printf("nnn"); printf(" - 欢迎进入还车界面 -"); printf("nn请你输入你的卡号 :"); scanf("%d",&cardnum); for(i=0;i<5;i+) if(cardi.cardnum=cardnum) n=i; printf("n请输入你要归还的车型:"); scanf("%s",lendcar); for(i=0;i<5;i+) while(strcmp(memberi.lendcar,lendcar)=0) cari.turefalse=1; break; printf("nn-还车完毕."); printf("n-按任意键返回.n"); getch(); return 1; printf("nn-租赁记录不存在.");printf("n-按任意键返回.n"); getch(); return 0; else printf("nn-卡号不存在,请与管理员联系.n"); printf("n-按任意键返回.n"); getch(); return 0;void addcard() int i=0; char choice; for(i=0,choice='y'choice='y'|choice='Y'i+) printf("nn卡号:"); scanf("%d",&cardi.cardnum); printf("n性别:"); scanf("%s",cardi.sex); printf("n姓名:"); scanf("%s",cardi.membersname); printf("n电话:"); scanf("%ld",&cardi.memberstel); printf("nn是否要输入下一个人=(y n)nn"); scanf("%s",&choice); printf("nn-输入完毕.");printf("n-任意键返回.n"); getch(); delcard() int i; int cardnum; char choice; printf("nn要删除的卡号:"); scanf("%d",&cardnum); for(i=0;i<5;i+) while(cardi.cardnum=cardnum) printf("nn确认删除? (Y / N)n"); scanf("%s",&choice); if(choice='y'|choice='Y') for(;i<5;i+) cardi=cardi+1; printf("nn-已删除成功!n-按任意键返回.n"); getch(); return 0; else printf("-已取消删除nn"); getch(); return 0; void cardcount() int i,n=0; for(i=0;i<5;i+) if(cardi.cardnum!=0) printf("第%d张卡 n",i+1); printf(" 卡号 性别 姓名 电话n"); printf("ttn"); printf(" %d %6s %10s %ld nn",cardi.cardnum,cardi.sex,cardi.membersname,cardi.memberstel); n+; printf("n"); printf("-目前共有%d个会员.n",n); printf("-按任意键返回.n"); getch(); void addcar() char choice; int i; for(i=0,choice='y'choice='y'|choice='Y'i+) printf("nnn编号:"); scanf("%d",&cari.carnum); printf("nn车型:"); scanf("%s",cari.carname); printf("nn品牌:"); scanf("%s",cari.carcreat); printf("nn租金:"); scanf("%f",&cari.carprice); printf("nn请你设定车的状态=(0-不在 1-在):"); scanf("%d",&cari.turefalse); printf("nn是否要输入下一辆车=(y n)nn"); scanf("%s",&choice); printf("nn-输入完毕.");printf("n-任意键返回.n"); getch(); delcar() int i,carnum; char choice; printf("nn"); printf("编号:n"); scanf("%d",&carnum); for(i=0;i<5;i+) while(carnum=cari.carnum) printf("确认删除-(y / n)?n"); scanf("%s",&choice); if(choice='y'|choice='Y') for(;i<5;i+) cari=cari+1; printf("nn-已删除成功!n-按任意键返回.n"); getch(); return 0; else printf("-已取消删除nn"); printf("-按任意键返回.n"); getch(); return 0; void carcount() int i,n=0; for(i=0;i<5;i+) if(cari.carnum!=0&&cari.carname!=0) printf("nn第%d辆车n编号 车型 品牌 租金 状态n",i+1); printf("ttn"); printf(" %d %10s ",cari.carnum,cari.carname); printf("%15s %4.2f %d=(1在0不在)nn",cari.carcreat,cari.carprice,cari.turefalse); n=n+1; printf("nn-目前共有%d辆车.n",n); printf("-按任意键返回.n"); void end() printf("nnn-n"); printf("n"); printf(" - 谢谢使用本系统, 再见! -n"); printf("nnnn"); void main() char ch1,ch2,ch4; do printf("n"); printf(" - 制作: 学号: 班级: - nn"); printf("n - 欢迎使用系统 -");printf("nn"); printf(" 请选择需要的服务:n"); printf(" 1:查询汽车n"); printf(" 2:办理租赁n"); printf(" 3:管理系统 n"); printf(" 4:归还登记n"); printf(" 0:退出系统 n"); printf("请输入数字04:n"); ch1=getch(); switch(ch1) case '1':chacar();break; case '2':lendcar();break; case '3': do printf("nn 1:增加汽车n"); printf(" 2:删除汽车 n"); printf(" 3:汽车统计 n"); printf(" 4:会员管理系统n"); printf(" 0:返回首页 n"); printf("请输入04:n"); ch2=getch(); switch(ch2) case '1':addcar(); break; case '2':delcar();break; case '3':carcount();getch();break; case '4': do printf("nn 1: 申请新卡 n"); printf(" 2: 删除卡号 n"); printf(" 3: 卡号统计n"); printf(" 0: 返回n"); printf("请输入03:n"); ch4=getch(); switch(ch4) case '1':addcard();break; case '2':delcard();break; case '3':cardcount();break; case '0':break; default:printf("无此操作!n");getch();break; while(ch4!='0');break; case '0':end();break; default:printf("无此操作!n");getch();break; while(ch2!='0');break; case '4':huancar();break; case '0':end();break; default:printf("无此操作!n");getch();break; while(ch1!='0'); -第 10 页-