提交 318d690d 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 e9427f4d
#ifndef LINEARLIST_H_
#define LINEARLIST_H_
//
// Include the C standard library header file here
//
#include <stdio.h>
//
// Other header files are included here
//
//
// Define the data structure here
//
......@@ -24,9 +19,13 @@
typedef int ElemType; // The types of elements in a linear table
typedef struct {
ElemType Elements[MAX_LENGTH]; // An array is used to store elements in a linear table whose maximum length is the length of the array.
int nLength; // The actual length of the linear table, the number of elements in the linear table.
typedef struct SqListElem
{
// An array is used to store elements in a linear table
// whose maximum length is the length of the array.
ElemType Elements[MAX_LENGTH];
// The actual length of the linear table, the number of elements in the linear table.
int nLength;
}SqList;
......@@ -36,5 +35,4 @@ typedef struct {
int InsertBefore(SqList* pList, ElemType Elem, int i);
#endif /* LINEARLIST_H_ */
#include "LinearList.h"
int main(int argc, char* argv[])
{
SqList List;
......@@ -11,8 +10,10 @@ int main(int argc, char* argv[])
// Initialize the linear table
//
List.nLength = 8;
for(i=0; i<List.nLength; i++)
for (i=0; i<List.nLength; i++)
{
List.Elements[i] = i;
}
//
// Insert the element before the ith element
......@@ -20,7 +21,7 @@ int main(int argc, char* argv[])
InsertBefore(&List, 18, 4);
InsertBefore(&List, 20, 11); // Invalid insert position. Insert failed.
for(i=0; i<List.nLength; i++)
for (i=0; i<List.nLength; i++)
{
printf("%d ", List.Elements[i]);
}
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论