2 qq 34324657 qq_34324657 于 2016.04.24 20:35 提问

数据结构运行出错,各位大神走一走,瞧一瞧!!!感激不尽!!!

#include
#include
#define ok 1;
#define overflow 0;
typedef int status;
typedef int elemtype;
const int list_init_size=100;
const int 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=0)
printf(%d,"0");

if{(b.length=k&&a.length[0]<b.length[0])
printf(%d,"1");
else printf(%d,"-1")}
}
int main()
{
seqlist a,b;
elemtype data;
initlist(a,b)

printf("输入顺序表a的元素值:\n");
for(int i=1;i<=10;i++)
{
scanf("%d",&data);
a.elem[i]=data;
a.length++;

}

printf("输入顺序表b的元素值:\n");
for(i=1;i<=10;i++)
{
scanf("%d",&data);
b.elem[i]=data;
b.length++;

}

compare(a,b);

}
错误:C:\Users\dell\Desktop\2.cpp(17) : error C2143: syntax error : missing ')' before ';'
可是我没觉得这里有错吖,心塞塞

2个回答

u010783161
u010783161   2016.04.24 21:53

这样的问题,估计只能通过删除一个个模块的代码来找错误点了,八成是你写代码时,漏了啥东东

qq_27142223
qq_27142223   2016.04.25 01:05

错误提示很明显了啊,少了括号,你用的什么编译器?开括号匹配了没?

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!