实现下列函数:
int Search(SSTable s, KeyType k);
/* Index the element which key is k */
/* in StaticSearchTable s. */
/* Return 0 if x is not found. */
静态查找表的类型SSTable定义如下:
typedef struct {
KeyType key;
... ... // 其他数据域
} ElemType;
typedef struct {
ElemType *elem;
int length;
int Search(SSTable s, KeyType k);
/* Index the element which key is k */
/* in StaticSearchTable s. */
/* Return 0 if x is not found. */
静态查找表的类型SSTable定义如下:
typedef struct {
KeyType key;
... ... // 其他数据域
} ElemType;
typedef struct {
ElemType *elem;
int length;
} SSTable;
int Search(SSTable a, KeyType k)
/* Index the element which key is k */
/* in StaticSearchTable s. */
/* Return 0 if x is not found. */
{
int i;
for(i=1;i<=a.length;i++)
{
if(a.elem[i].key==k)return i;
}
return 0;
}