标题:线性表疑问?
只看楼主
henji
Rank: 1
等 级:新手上路
帖 子:227
专家分:0
注 册:2009-4-19
结帖率:38.67%
 问题点数:0 回复次数:2 
线性表疑问?
#include <stdio.h>
#include <stdlib.h>
#include <iostream.h>
#define     OK      1
#define     ERROR     0
#define     OVERFLOW     -2
typedef     int     ElemType;   
typedef     int Status;


#define     LIST_INIT_SIZE 100
#define     LISTINCREMENT     10
typedef     struct
{
     ElemType *elem;//elem是整数类型的指针吗?
     int length;
     int listsize;   
}SqList;


Status InitList_Sq(SqList &L)
{
          int i;
          L.elem = (ElemType * )malloc(LIST_INIT_SIZE*sizeof(ElemType));//L.elem的数据类型是指针类型吗?
          if (! L.elem) exit (OVERFLOW);
              for(i=1;i<=5;i++)
              {
                  printf("input elem:\n");
                  scanf("%d",&L.elem[i-1]);
              
              }

          L.listsize = LIST_INIT_SIZE;
          return OK;
}
搜索更多相关主题的帖子: 疑问 线性 
2010-03-24 15:01
llooppzhang
Rank: 7Rank: 7Rank: 7
来 自:江苏
等 级:黑侠
威 望:5
帖 子:308
专家分:518
注 册:2009-10-18
得分:0 
en
2010-03-24 15:02
henji
Rank: 1
等 级:新手上路
帖 子:227
专家分:0
注 册:2009-4-19
得分:0 
回复 2楼 llooppzhang
Status InitList_Sq(SqList &L)
{
          int i;
          L.elem = (ElemType * )malloc(LIST_INIT_SIZE*sizeof(ElemType));
          if (! L.elem) exit (OVERFLOW);
              for(i=1;i<=5;i++)
              {
                  printf("input elem:\n");
                  scanf("%d",&L.elem[i-1]);//如果L.elem是指针类型那么在输入的时候为什么还要加取地址符&呢?
              
              }

          L.listsize = LIST_INIT_SIZE;
          return OK;
}
2010-03-24 15:11



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-300406-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.261400 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved