线性表的查找代码.doc_第1页
线性表的查找代码.doc_第2页
线性表的查找代码.doc_第3页
线性表的查找代码.doc_第4页
免费预览已结束,剩余1页可下载查看

下载本文档

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

文档简介

#include #include #include #define M 3 #define B 3 #define S 6 typedef char datatype;typedef char keytype;typedef struct char num8; char name10; int chin;int phy;int chem;int eng; STUDENT; STUDENT studM;typedef struct keytype key8; STUDENT stu; TABLE;typedef struct keytype key8; int low,high; INDEX;TABLE listM; INDEX inlistB; int save() FILE *fp; int i; if(fp=fopen(score.txt,wb)=NULL) printf(Canneot open file!n); return 0; printf(n文件的内容是:nn); for(i=0;iM;i+) fprintf(fp,%s,studi.num); printf(%s,studi.num); fprintf(fp,%s,); printf(%s,); fprintf(fp,%s,studi.chin); printf(%s,studi.chin); fprintf(fp,%s,studi.phy); printf(%s,studi.phy); fprintf(fp,%s,studi.chem); printf(%s,studi.chem); fprintf(fp,%s,studi.eng); printf(%s,studi.eng); fprintf(fp,n); printf(n); fclose(fp);void creat() int i; printf(请输入18个学生号、名字、四门成绩:n); for(i=0;iM;i+) scanf(%s%s%d%d%d%d,studi.num,,&studi.chin,&studi.phy,&studi.chem,&studi.eng); save();void readtxt(void) FILE *fp; int i,d; char max8; fp=fopen(score.txt,r); for(i=0;iM;i+) fscanf(fp,%s,listi.stu.num); fscanf(fp,%s,); fscanf(fp,%d,&listi.stu.chin); fscanf(fp,%d,&listi.stu.phy); fscanf(fp,%d,&listi.stu.chem); fscanf(fp,%d,&listi.stu.eng); strcpy(listi.key,listi.stu.num); for(i=0;iB;i+) inlisti.low=i+(i*(S-1); inlisti.high=i+(i+1)*(S-1); strcpy(max,list0.stu.num);d=0;for(i=1;iM;i+) if(strcmp(max,listi.stu.num)0) strcpy(max,listi.stu.num); if(i+1)%6 = 0 ) strcpy(inlistd.key,max); d+; if(iM-1) strcpy(max,listi+1.stu.num);i+; fclose(fp); void modify (char *key,int kc,int cj) int low1=0,high1=B-1,mid1,i,j; int flag=0; while(low10) high1=mid1-1; else low1=mid1+1; if (low1B) i=inlistlow1.low;j=inlistlow1.high; while(ij & strcmp(listi.key,key) i+; if(strcmp(listi.key,key)=0) if(kc=1) listi.stu.chin=cj; else if(kc=2) listi.stu.phy=cj; else if(kc=3) listi.stu.chem=cj; else if(kc=4) listi.stu.eng=cj;void writetxt(void) FILE *fp; int i; fp=fopen(score.txt,w); for(i=0;iM;i+) fprintf(fp,%s ,listi.stu.num); fprintf(fp,%s ,); fprintf(fp,%d ,listi.stu.chin); fprintf(fp,%d ,listi.stu.phy); fprintf(fp,%d ,listi.stu.chem); fprintf(fp,%d ,listi.stu.eng); fprintf(fp,n); fclose(fp); int main( ) int kc,cj; creat(); char key8; printf(请输入欲修改成绩的学生号!n); gets(key); printf(选择欲修改成绩的课

温馨提示

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

评论

0/150

提交评论