注册 登录
编程论坛 数据结构与算法

线性表的顺序表示

雄哥现世 发布于 2013-03-09 15:04, 648 次点击
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
  typedef struct
  {
    int *Elem;
    int length;
    int listsize;

  }SqList;
  void InitList(SqList &L)
 {
   
    L.Elem=(int*)malloc(LIST_INITIAL_SIZE*sizeof(int));
   L.Length =0;
   L.listsize =LIST_INIT_SIZE 100;
 }



 void main()
 {
      SqList s;
     Init_List(s);

 为什么这段程序显示错误??求大神解答,提示错误说void InitList(SqList &L)说明语法错误。。
5 回复
#2
yuccn2013-03-09 17:46
void InitList(SqList &L)
Init_List(s); 你不发现有什么不一样吗
#3
yuccn2013-03-09 17:49
L.listsize =LIST_INIT_SIZE 100;  这个是什么意思?

还有:
typedef struct
   {
     int *Elem;
     int length;
     int listsize;
 
  }SqList;


 L.Length =0;

哥哥,细心点啊

#4
雄哥现世2013-03-09 20:17
回复 3楼 yuccn
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
  typedef int ElemType;
   typedef struct
  {
     ElemType *Elem;
    int length;
    int listsize;

  }SqList;
  void InitList(SqList &L)
 {
   L.ELem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
   L.length =0;
   L.listsize =LIST_INIT_SIZE ;
 }


 void main()
 {
      SqList s;
     InitList(s);

 }我都改过了,可是还是不对。。。。
我用WIN-TC编译的,这是错误提示
错误 list.c 14: 说明语法错误在void InitList(SqList &L)。
#5
不玩虚的2013-03-09 23:35
#include<iostream>
using namespace std;
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
   typedef struct SqList
  {
     int *Elem;
    int length;
    int listsize;

  }SqList;
  void InitList(SqList &L)
{
      L.Elem=new int[LIST_INIT_SIZE];
   L.length =0;
   L.listsize =LIST_INIT_SIZE ;
}


void main()
{
      SqList s;
     InitList(s);

}//
#6
不玩虚的2013-03-09 23:43
#include<stdio.h>
#include<malloc.h>
#include<conio.h>
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
  typedef struct   
  {
    int *Elem;
    int length;
    int listsize;

  }SqList;
  void InitList(SqList &L)
{
   
    L.Elem=(int*)malloc(LIST_INIT_SIZE*sizeof(int));
   L.length =0;
   L.listsize =LIST_INIT_SIZE;
}



void main()
{
      SqList s;
     InitList(s);

}//注意大小写,还有#define 语句是干嘛的,怎么用,同一个变量别打错了,注意书写格式和大小写,多一个少一个都不是那个变量啦
1