摘要:
问题:明白思想,其他的没什么,记得结构体为指针时一定要动态分配内存。代码:#include <iostream>#include <cstdlib>using namespace std;#define MAXL 20typedef struct seq{ int key[MAXL]; int len;}data;typedef struct table{ int start; int end; int d;}index[4];int block_search(index s,data *list,int key) //分块查找{ int i=0; int j; whi 阅读全文
摘要:
比较简单,主要是明白算法思想。代码:#include <iostream>#include <cstdlib>using namespace std;int main(){ cout<<"/"<<"折半查找"<<"/"<<endl; cout<<"-------------------"<<endl; int arr[10]={1,2,3,4,5,6,7,8,9,10}; int low,high,mid; int ke 阅读全文
摘要:
#include <iostream>#include <cstdlib>using namespace std;#define MAXL 20typedef struct data{ int d[MAXL]; int len;}arr;int searchKey(arr *a,int key){ int i; a->d[0]=key; for(i=a->len-1;i>0;i--) { if(a->d[i]==key) { return i; } } }int main(){ arr *a; a=(arr*)malloc(sizeof(stru 阅读全文