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

线性表问题,求各位指教

qwe885167759 发布于 2013-10-20 22:08, 664 次点击
#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 编辑 ]
1 回复
#2
qunxingw2013-10-21 11:10
typedef  int   Stutas ;
Sqlist L;
Status Initlist_Sq(Sqlist * L,int n)
先解决提示信息的
1