资源描述:
《车友信息管理系统详细编程》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、先建立四个头文件cr.h;prepare.h;file.h;list.h;;;;在D盘建立一个“文件.txt”即可。文件代码cr.h#ifndef_CR#define_CR#includestructCarfriend{longVIPnum;charname[10];charsex[7];charjob[10];intage[2];charbrand[10];chartype[7];charcolour[8];};typedefstructCarfriendType;constintsizeCfr=sizeof(Ty
2、pe);//车友信息所需要的内存空间大小structnode{Typedata;structnode*next;};constintsize=sizeof(structnode);//结点所需要的内存空间的大小#endifPrepare.h#ifndef_PREPARE#define_PREPARE#include"cr.h"#include#includevoidprintHead()//打印表头函数{printf("%8s%9s%9s%9s%7s%7s%13s%7s%7s","会员名","
3、昵称","性别","职业","驾龄","年龄","车辆品牌","车款","颜色");}voidprintNode(Typedata)//输出结点所有数据域的值{inti;printf("%8ld",data.VIPnum);printf("%9s",data.name);printf("%9s",data.sex);printf("%9s",data.job);for(i=0;i<2;i++)printf("%7d",data.age[i]);printf("%13s",data.brand);printf("%7s",data.ty
4、pe);printf("%7s",data.colour);}voidreadNode(Type*pdata)//根据提示读入结点的相关数据域的值{inti;printf("Inputonecarfriend'sinformation");printf("VIPnum:");scanf("%ld",&pdata->VIPnum);printf("name:");scanf("%s",&pdata->name);printf("sex(MaleorFemale):");scanf("%s",&pdata->sex);printf(
5、"job:");scanf("%s",&pdata->job);printf("Inputthedrivingyearsandtheageofthecarfriend");for(i=0;i<2;i++){scanf("%d",&pdata->age[i]);}printf("brandofthecar:");scanf("%s",&pdata->brand);printf("type:");scanf("%s",&pdata->type);printf("colourofthecar:");scanf("%s",&pdata->
6、colour);}intendWith(Typedata)//输入结点数据时会员名域为0作为结束条件{returndata.VIPnum==0;}intequal(Typedata1,Typedata2,intcondition){if(condition==1)if(strcmp(data1.brand,data2.brand)==0)return0;elsereturn1;elseif(condition==2)if(strcmp(data1.sex,data2.sex)==0)return0;elsereturn1;elsere
7、turn1;}intlarger(Typedata1,Typedata2,intcondition){if(condition==1)returndata1.age[1]>data2.age[1];return1;}#endiffile.h#include#include#include"list.h"voidcreateFile()//建立初始的数据文件{Typedata;intn,i;FILE*fp;if((fp=fopen("D:\文件.txt","w"))==NULL)//指定好文件名,
8、以写入方式打开{printf("cannotopenfilecashbox.txt!");//若打开失败,输出提示信息,退出exit(0);}printf("howmanyrecordsdoyouwanttoadd?