设计一个算法,将x插入到一个有序的线性表的适当位置,并保持线性表的有序性

whdugh whdugh 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
#include <stdio.h>
#include <stdlib.h>
#define MaxSize 10
typedef char ElemType;
typedef struct
{
ElemType elem[MaxSize];
int length;
} SqList;
void Insert(SqList *&A, ElemType x) //error1:excepted ';',','or ')'before '&'token.
{
int i = 0, j;
while(i < A.length && A.elem[i] < x)
i++;
for(j = A.length - 1; j >= i; j--)
A.elem[j+1] = A.elem[j];
A.elem[i] = x;
A.length++;
}
int main()
{
SqList *p;
int i;
p = (SqList*)malloc(sizeof(SqList));
for(i = 0; i < p->length; i++)
scanf("%c",p->elem[i]);
Insert(p,8);
for(i = 0; i < p->length; i++)
printf("%c", p->elem[i]);
return 0;
}

有一处错误 这个要怎么改 谢谢
...全文
评论 11
收藏 已收藏
分享
返回顶部
whdugh
C语言 70,039 成员 243,237 内容