| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 664 人关注过本帖
标题:线性表问题,求各位指教
只看楼主 加入收藏
qwe885167759
Rank: 4
等 级:业余侠客
威 望:5
帖 子:148
专家分:259
注 册:2013-3-12
结帖率:72.22%
收藏
已结贴  问题点数:10 回复次数:1 
线性表问题,求各位指教
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#define  LIST_INIT_SIZE   100
#define  LISTINREMENT    10
typedef  struct list
{
    struct list * elem;
    int   length;
    int   listsize;
    char  a;
} Sqlist;
typedef  int   Stutas ;
Sqlist L;
Status Initlist_Sq(Sqlist * L,int n)
{
     L.elem=(Sqlist*)malloc(LIST_INIT_SIZE*sizeof (int));
     if(!L.elem)  return (0);
     L.length=0;
     L.listsize=LIST_INIT_SIZE;
     for (int i=0;i<n;i++)
     {
         if(L.length>=l.listsize)
             printf("当前存储空间已满!\n");
         else
         {
             L=L.elem;
             scanf("%f",&L.a[n]);
             L.length++;
             ++L.elem;
         }
     }
}

Status  LisInsert_Sq(Sqlist *L,int i, char e)
{
      struct  Sqlist *  newbase, * q, * p;
      if(i<1||i>L.length+1)
          return 0;
      if (L.length>=L.listsize)
      {
          newbase=(Sqlist *)realloc(L.elem,(L.listsize+LISTINCREMENT) * sizeof (char));
          if (!newbase) return 0;
          L.elem=newbase;
          L.listsize +=LISTINCREMENT;
      }
      q=&(L.a[i-1]);
      for(p=&(L.elem[L.length-1]);p<=q;--p)
          * (p+1)=* p;
      * q.a=e;
      ++L.length;
      return 0;
}

Status  listDelete_Sq(Sqlist * L,int j,char * e)
{
      if(j<1||j>L.length)
          return 0;
      p=&(L.elem[i-1]);
      e=*p;
      q=l.elem+L.length-1;
      for(++p;p<=q;++p)
          *(p-1)=*p;
      --l.length;
      return 0;
}

Status  listprintf_Sq(Sqlist * L,int n)
{
     for (int k=0;k<n;k++)
     {
         printf("%f\t",L.a);
         ++L;
     }
}

void main ()
{
     int n;
     char e;
     struct Sqlist *p,*q;
     printf("请输入字符数:/n");
     scanf("%d",&n);
     Initlist_Sq(Sqlist * L,int n);
     printf("请输入插入位置:/n");
     scanf("%d",&i)
     listinser_Sq(Sqlist * L,int i,char e);
     printf("请输入删除元素的位置:/n");
     scanf("%d",&j)
     ListDelete_Sq(Sqlist *L,int j,char * e);
     listprintf(Sqlist * L,int n);
}

-------------------Configuration: 数据结构 - Win32 Debug--------------------
Compiling...
asd4.cpp
D:\C文件\数据结构\asd4.cpp(15) : error C2146: syntax error : missing ';' before identifier 'Initlist_Sq'
D:\C文件\数据结构\asd4.cpp(15) : error C2501: 'Status' : missing storage-class or type specifiers
D:\C文件\数据结构\asd4.cpp(15) : fatal error C1004: unexpected end of file found
执行 cl.exe 时出错.

asd4.obj - 1 error(s), 0 warning(s)


[ 本帖最后由 qwe885167759 于 2013-10-20 22:10 编辑 ]
搜索更多相关主题的帖子: 线性表 return include 
2013-10-20 22:08
qunxingw
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:贵宾
威 望:24
帖 子:1676
专家分:7295
注 册:2011-6-30
收藏
得分:10 
typedef  int   Stutas ;
Sqlist L;
Status Initlist_Sq(Sqlist * L,int n)
先解决提示信息的

www.qunxingw.wang
2013-10-21 11:10
快速回复:线性表问题,求各位指教
数据加载中...
 
   



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

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