求幫忙

#include"yuchuli.h"
#define LIST_INIT_SIZE 100
#define LISTINCREMENT 10
typedef struct
{
 ElemType *elem;
 int  length;
 int  listsize;
}SqList;

#include"yuchuli.h"
#include"stdafx.h"
#include"jiguot.h"
#include"malloc.h"
#include"stdlib.h"

Status InitList_Sq(SqList &L)
{
 int OVERFLOW;
 L.elem=(ElemType *)malloc(LIST_INIT_SIZE*sizeof(ElemType));
 if(!L.elem)exit(OVERFLOW);
 L.length = 0;
 L.listsize = LIST_INIT_SIZE;
 return 0;
}


#include"stdafx.h"
#include"jiguot.h"
#include"malloc.h"
#include"stdlib.h"


Status ListInitList_Sq(SqList &L, int i, ElemType e)
{

 int *q=NULL,*p=NULL;
 int ERROR,*newbase,OVERFLOW;
 if(i<1||i>L.length+1)return ERROR;
 if(L.length>=L.listsize)
 {
  newbase=(ElemType *)realloc(L.elem,(L.listsize+LISTINCREMENT)*sizeof(ElemType));
  if(!newbase)exit(OVERFLOW);
  L.elem=newbase;
  L.listsize +=LISTINCREMENT;
 }
 q=&(L.elem[i-1]);
 for(p=&(L.elem[L.length-1]);p>=q;--p)*(p+1)=*p;
 *q = e;
 ++L.length;
 return 0;
}


#include "stdafx.h"
#include"stdio.h"
#include"jiguot.h"
#include"malloc.h"
#include"stdlib.h"
#define N 5
Status ListInitList_Sq(SqList &L, int i, ElemType e);
Status InitList_Sq(SqList &L);

int _tmain(int argc, _TCHAR* argv[])
{
 int a[N],c,x,i=0;
 SqList List={NULL,0, 0};
 SqList L;
 if(InitList_Sq( List))
 {
  printf("請輸入五個數:\n");
  for(c=1;c<N;c++)
  {
   scanf("%d",&a[c]);
  }
 }
 printf("請輸入插入的位置,插入的數:\n");
 scanf("%d\n%d",&i,&x);
 InitList_Sq(List, i, x);
 printf("%d",List.elem[0]);
 int m;
 scanf("%d",&m);
 return 0;
}

在一個線性表中插入一個數
主函數爲什麼會出現InitList_Sq(List, i, x);  不能接受3個參數??
 求解

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章