数据结构源码笔记(C语言):索引文件建立和查找

您所在的位置:网站首页 C语言索引交换 数据结构源码笔记(C语言):索引文件建立和查找

数据结构源码笔记(C语言):索引文件建立和查找

2024-07-15 11:22| 来源: 网络整理| 查看: 265

//实现索引文件建立和查找算法 #include #include #include #include #define MaxRec 100//最多的记录个数 typedef struct Index //定义索引文件结构 { char num[8];//学号 long offset;//主文件中的记录号 }Index; typedef struct sdata//定义主文件结构 { char num[8]; char name[10]; int sex; int age; char addr[30]; char dep[20]; char spec[20]; }Student; void DelAll()//清除主文件和索引文件的全部记录 { FILE *mfile,*idxfile; if((mfile=fopen("main.dat","wb"))==NULL) { printf(">>不能打开主文件\n"); return; } if((idxfile=fopen("idx.dat","wb"))==NULL) { printf(">>不能打开索引文件\n"); return; } fclose(mfile); fclose(idxfile); } void InsertSort(Index r[],int n)//对r[0......n-1]按递增有序进行直接插入排序 { int i,j; Index temp; for(i=1;i=0 && strcmp(temp.num,r[j].num)


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3