回 帖 发 新 帖 刷新版面

主题:这个要用到数据结构,我不知道哪里错了,麻烦各位高手帮忙找找。急!急!急!

# include <stdio.h>
typedef int ElemType;
# define LIST_INIT_SIZE 100
# define LISTINCREAMENT 10
typedef struct{
         ElemType *elem,*newbase;
         int length,listsize;
        }Sqlist;
struct Status ListIncreament(Sqlist &L)
{newbase=( ElemType*)realloc(L.elem,(L.listsize+LISTINCREAMENT)*sizeof( ElemType));
if(!newbase)exit(ORERFLOW);
L.elem=newbase;
L.listsize+=LISTINCREAMENT;}
Status InitList_Sq(Sqlist &L){
    L.elem=( ElemType*)malloc(LIST_INIT_SIZE*sizeof( ElemType));
    if(!L.elem)exit(OVERFLOW);
    L.length=0;
    L.listsize=LIST_INIT_SIZE;
    return ok;
}
void main()
{
    int i=1,a,m;
    printf("请输入字母个数");
    scanf("%d",&a);
    if(a>100)
        ListIncreament;
    L.length=a;
    while(i<=a)
    {
        scanf("%d",&m);
        L.elem[i-1]=m;
        i++;
    }
}

回复列表 (共1个回复)

沙发

struct Status ListIncreament(Sqlist &L)
struct Status 是什么?
newbase 没定义,也没有初始化。

我来回复

您尚未登录,请登录后再回复。点此登录或注册