#include "stdlib.h"
#include "stdio.h"
#define MAX 100
struct SeqList
{
int date[MAX];
int length;
} //定义顺序表
typedef struct SeqList *PSeqList;
PSeqList creatSeqList(void)
{
PSeqList SeqListPoint;
SeqListPoint=(PSeqList)malloc(sizeof(struct SeqList));
if (SeqListPoint)
SeqListPoint.length=0;
return (SeqListPoint);
} //创建顺序表;
void DestorySeqList(PSeqlist *SeqListPoint)
{
if (*SeqListPoint)
free (*SeqListPoint);
*SeqListPoint=NULL;
return;
} //销毁顺序表;
int insertSeqList(PSeqlist *SeqListPoint,int i,int x) //表,位置,数字
{
int j;
if (!SeqlistPoint)
{
printf("There is no the list!");
return (-2);
}
if (SeqListPoint.length>=MAX)
{
printf("There is no vacantness!");
return (-1);
}
if ((i<1)||(i>SeqListPoint.length+1)
{
printf("Here can not be inserted!");
return (0);
}
for (j=SeqListPoint.length-1;j>=i-1;j--)
SeqListPoint.date[j+1]=SeqListPoint.date[j];
SeqListPoint.date[i-1]=x;
SeqListPoint.length++;
return (1);
} //顺序表插入
main()
{
PSeqList list;
int i,place,num;
list=creatSeqList();
printf("Where you want to insert and What's number:");
scanf("%d,%d",place,num);
for (i=0;i<=10;i++)
{
list.length++;
list.date[i]=i;
}
for (i=0;i<=list.length-1;i++)
printf("%d ",list.date[i]);
insertSeqList(list,place,num);
for (i=0;i<=list.length-1;i++)
printf("%d ",list.date[i]);
DestorySeqList(list);
}
我学的是C数据结构,而用的是VC++6。0环境,因为这个编起来舒服一些```
这个程序在VC++6。0下没有报错和警告,可是运行就说“程序无法执行”,郁闷半天。
而老师给的程序却可以顺利通过。
请指点一下!