欢迎来到天天文库
浏览记录
ID:13584387
大小:35.00 KB
页数:5页
时间:2018-07-23
《线性表的查找代码》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、#include#include#include#defineM3#defineB3#defineS6typedefchardatatype;typedefcharkeytype;typedefstruct{charnum[8];charname[10];intchin;intphy;intchem;inteng;}STUDENT;STUDENTstud[M];typedefstruct{keytypekey[8];STUDENTstu;}TABLE;typedefstruct{keytypekey[8];
2、intlow,high;}INDEX;TABLElist[M];INDEXinlist[B];intsave(){FILE*fp;inti;if((fp=fopen("score.txt","wb"))==NULL){printf("Canneotopenfile!");return0;}printf("文件的内容是:");for(i=0;i3、tud[i].name);fprintf(fp,"%s",stud[i].chin);printf("%s",stud[i].chin);fprintf(fp,"%s",stud[i].phy);printf("%s",stud[i].phy);fprintf(fp,"%s",stud[i].chem);printf("%s",stud[i].chem);fprintf(fp,"%s",stud[i].eng);printf("%s",stud[i].eng);fprintf(fp,"");printf("");}fclose(fp);}voidcreat4、(){inti;printf("请输入18个学生号、名字、四门成绩:");for(i=0;i5、fscanf(fp,"%s",list[i].stu.name);fscanf(fp,"%d",&list[i].stu.chin);fscanf(fp,"%d",&list[i].stu.phy);fscanf(fp,"%d",&list[i].stu.chem);fscanf(fp,"%d",&list[i].stu.eng);strcpy(list[i].key,list[i].stu.num);}for(i=0;i6、ax,list[0].stu.num);d=0;for(i=1;i7、1<=high1&&!flag){mid1=(low1+high1)/2;if(strcmp(inlist[mid1].key,key)==0)flag=1;elseif(strcmp(inlist[mid1].key,key)>0)high1=mid1-1;elselow1=mid1+1;}if(low18、tu.ch
3、tud[i].name);fprintf(fp,"%s",stud[i].chin);printf("%s",stud[i].chin);fprintf(fp,"%s",stud[i].phy);printf("%s",stud[i].phy);fprintf(fp,"%s",stud[i].chem);printf("%s",stud[i].chem);fprintf(fp,"%s",stud[i].eng);printf("%s",stud[i].eng);fprintf(fp,"");printf("");}fclose(fp);}voidcreat
4、(){inti;printf("请输入18个学生号、名字、四门成绩:");for(i=0;i5、fscanf(fp,"%s",list[i].stu.name);fscanf(fp,"%d",&list[i].stu.chin);fscanf(fp,"%d",&list[i].stu.phy);fscanf(fp,"%d",&list[i].stu.chem);fscanf(fp,"%d",&list[i].stu.eng);strcpy(list[i].key,list[i].stu.num);}for(i=0;i6、ax,list[0].stu.num);d=0;for(i=1;i7、1<=high1&&!flag){mid1=(low1+high1)/2;if(strcmp(inlist[mid1].key,key)==0)flag=1;elseif(strcmp(inlist[mid1].key,key)>0)high1=mid1-1;elselow1=mid1+1;}if(low18、tu.ch
5、fscanf(fp,"%s",list[i].stu.name);fscanf(fp,"%d",&list[i].stu.chin);fscanf(fp,"%d",&list[i].stu.phy);fscanf(fp,"%d",&list[i].stu.chem);fscanf(fp,"%d",&list[i].stu.eng);strcpy(list[i].key,list[i].stu.num);}for(i=0;i
6、ax,list[0].stu.num);d=0;for(i=1;i7、1<=high1&&!flag){mid1=(low1+high1)/2;if(strcmp(inlist[mid1].key,key)==0)flag=1;elseif(strcmp(inlist[mid1].key,key)>0)high1=mid1-1;elselow1=mid1+1;}if(low18、tu.ch
7、1<=high1&&!flag){mid1=(low1+high1)/2;if(strcmp(inlist[mid1].key,key)==0)flag=1;elseif(strcmp(inlist[mid1].key,key)>0)high1=mid1-1;elselow1=mid1+1;}if(low1
8、tu.ch
此文档下载收益归作者所有