帮忙看一下以下的代码,我找不到哪里错了?
#include<iostream.h>#include<stdlib.h>
const list_init_size=100;
const listincrement=10;
typedef int elemtype;
typedef struct //顺序表的空间分配
{
elemtype * elem;//一维数组
int length;
int listsize;
int incrementsize;
}sqlist;
void initlist_sq(sqlist &l)//生成顺序表的空间
{
l.elem=new elemtype[list_init_size];//生成动态数组
l.length=0;
l.listsize=list_init_size;
l.incrementsize=listincrement;
}
void inversion(sqlist &l)
{
int i=0;
elemtype e,*p,*q;
for(i=0;i<l.length;i++)
{
p=&(l.elem[l.length-1]);//每次删除最后一个元素
e=*p;//把最后一个元素赋值给e
q=&(l.elem[i+1]);//插入位置
for(p;p>=q;--p)
{
*(p+1)=*p;
}
*q=e;//插入e
}
int main()
{
sqlist l;
initlist_sq(l);
l.elem[]={1,2,3,4,5,6};
inversion(l);
return 0;
}
报错点:C:\Users\zxq\Desktop\20151152091\2-6.cpp(6) : error C2601: 'main' : local function definitions are illegal
C:\Users\zxq\Desktop\20151152091\2-6.cpp(15) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.