#include<stdio.h>
#include<stdlib.h>
#define    TRUE    1
#define    FALSE    0
#define    OK        1
#define    ERROR    0
#define    INFEASIBLE    -1
#define    OVERFLOW    -2
typedef    int    Status;
typedef    int ElemType;
#define    LIST_INIT_SIZE    100
#define    LISTINCREMENT    10
typedef struct
{
    ElemType *elem;
    int length;
    int listsize;
}SqList;
Status InitList_Sq(SqList *L)                  // 构造空的线性表
{
    L->elem = (ElemType *)malloc(LIST_INIT_SIZE * sizeof(ElemType));
    if (! L->elem)
    {
        printf("构造失败!\n");
        exit(OVERFLOW);
    }
    L->length = 0;
    L->listsize = LIST_INIT_SIZE;
    printf("构造成功!\n");
    return OK;
}
int compare(int a,int b)
{if(a=b)
   return 1;
 return 0;
 
}
Status LocateElem_Sq(SqList L, ElemType e, Status (* compare)(ElemType, ElemType))        // 在L中找到一个值与e满足compare()的元素的位序
{
    int i = 1;
    int *p = L.elem;
    while (i <= L.length && !(* compare)(*p ++, e))
    {
        i++;
    }
    if (i <= L.length)
    {
        return i;
    }
    else
    {
        return 0;
    }
}/*指向函数的指针*/Status main(void)
{
    SqList L;
    ElemType i, m
    printf("初始化线性表···");
    InitList_Sq(&L);    }
    for (i = 1; i <= LISTINCREMENT; i ++)
    {
        L.elem[i - 1] = i;
        L.length ++;
    }
    printf("线性表内初始数值为:\n");
    for (i = 1; i <= LISTINCREMENT; i ++)
    {
        printf("%4d", L.elem[i - 1]);
    }
    printf("\n");
    m=LocateElem_Sq(L,3,compare);
    printf("与4相等的元素的位序%d",m);
return 0;
}