提交 3c86399f 创建 作者: 宋海霞's avatar 宋海霞

modify

上级 f916ceb4
#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;
......
#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 after the ith element
......@@ -20,7 +21,7 @@ int main(int argc, char* argv[])
InsertAfter(&List, 33, 5);
InsertAfter(&List, 45, 15); // 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论