#include <stdio.h>

int main()
{
    int T[5] = {2, 7, 12, 43, 60};

    /* 索引表 */
    int index[3] = {7, 43, 60};

    int key = 43;
    int i, j;
    int location = -1;

    printf("原始数据为：\n");

    for(i = 0; i < 5; i++)
    {
        printf("%d ", T[i]);
    }

    printf("\n查找关键字：%d\n", key);

    /* 查找所在的块 */
    for(i = 0; i < 3; i++)
    {
        if(key <= index[i])
            break;
    }

    /* 在对应块中进行顺序查找 */
    if(i < 3)
    {
        for(j = i * 2; j < (i + 1) * 2 && j < 5; j++)
        {
            if(T[j] == key)
            {
                location = j + 1;
                break;
            }
        }
    }

    if(location != -1)
        printf("查找成功！\n关键字的位置是：%d\n", location);
    else
        printf("查找失败！\n");

    return 0;
}