请教关于c语言语法 Status(*compare)(ElemType, ElemType)
Statuscompare(ElemTypex,ElemTypey){returnx==y;}intLocateElem_Sq(SqlistL,ElemTypee,Sta...
Status compare(ElemType x, ElemType y)
{
return x == y;
}
int LocateElem_Sq(Sqlist L, ElemType e, Status(*compare)(ElemType, ElemType))
{
//i为位置的值,赋初值为1
int i = 1;
//给p赋顺序表的基址,通过p++来遍历顺序表
ElemType* p = L.elem;
//这里的compare是在Status(*compare)(ElemType, ElemType)定义的
while (i <= L.length && !(*compare)(*p++, e))
{
++i;
}
if (i <= L.length)
return i;
else
return 0;
}
请问参数表中Status(*compare)(ElemType, ElemType)的作用 展开
{
return x == y;
}
int LocateElem_Sq(Sqlist L, ElemType e, Status(*compare)(ElemType, ElemType))
{
//i为位置的值,赋初值为1
int i = 1;
//给p赋顺序表的基址,通过p++来遍历顺序表
ElemType* p = L.elem;
//这里的compare是在Status(*compare)(ElemType, ElemType)定义的
while (i <= L.length && !(*compare)(*p++, e))
{
++i;
}
if (i <= L.length)
return i;
else
return 0;
}
请问参数表中Status(*compare)(ElemType, ElemType)的作用 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询