问题描述
- 数据结构,编译运行出错。小妹感激不尽呐1!!!
-
#include
#include
#define list_init_size 100
#define listincrement 10
typedef struct{
Elemtype elem;
int length;
int listsize;
}seqlist;
status initlist(seqlist &a,seqlist &b)
a.elem=(elemType)malloc(list_init_size*sizeof(Elemtype));
if(!a.elem)exit(overflow);
a.length=0;
a.listsize=list_init_size;
b.elem=(ElemType*)malloc(list_init_size*sizeof(Elemtype));
if(!b.elem)exit(overflow);
b.length=0;
b.listsize=list_init_size;
return ok;
}
status compare(seqlist &a,seqlist &b)
{
int k, i;
k=a.length>b.length?a.length:b.length;
if(a.length=b.length=NULL)
printf(%d,"0");
printf(&d,"1");
if{(b.length=k&&a.length[0]<b.length[0])
else printf(%d,"-1")}
}
int main()
{
seqlist a,b;
printf("输入顺序表a的元素值:n");
for(int i=1;i<=10;i++)
{
scanf("%d",a[i]);} printf("输入顺序表b的元素值:n"); for(i=1;i<=8;i++) { scanf("%d",b[i]); } initlist(a,b); compare(a,b);
}
错误:C:UsersdellDesktop4.cpp(6) : error C2143: syntax error : missing ';' before '*'
解决方案
错误提示已经说得很清楚了呀。。你双击错误会告诉你在哪一行
解决方案二:
你的scanf函数用错了,应该是scanf(“%d”,a+i);scanf(“%d”,b+i);第二个参数是地址,不是值。
时间: 2024-11-01 11:31:26