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

modify

上级 bbba03b7
#ifndef LINEARLIST_H_ #ifndef LINEARLIST_H_
#define LINEARLIST_H_ #define LINEARLIST_H_
// //
// Include the C standard library header file here // Include the C standard library header file here
// //
#include <stdio.h> #include <stdio.h>
// //
// Other header files are included here // Other header files are included here
// //
// //
// Define the data structure here // Define the data structure here
// //
...@@ -24,17 +19,19 @@ ...@@ -24,17 +19,19 @@
typedef int ElemType; // The types of elements in a linear table typedef int ElemType; // The types of elements in a linear table
typedef struct { typedef struct SqListElem
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. // 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; }SqList;
// //
// Declare the function here // Declare the function here
// //
int Delete(SqList* pList, int i, ElemType* pElem); int Delete(SqList* pList, int i, ElemType* pElem);
#endif /* LINEARLIST_H_ */ #endif /* LINEARLIST_H_ */
没有这种文件类型的预览
#include "LinearList.h" #include "LinearList.h"
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
...@@ -11,8 +10,10 @@ int main(int argc, char* argv[]) ...@@ -11,8 +10,10 @@ int main(int argc, char* argv[])
// Initialize the linear table // Initialize the linear table
// //
List.nLength = 8; List.nLength = 8;
for(i=0; i<List.nLength; i++) for (i=0; i<List.nLength; i++)
{
List.Elements[i] = i; List.Elements[i] = i;
}
// //
// Delete the ith element // Delete the ith element
...@@ -20,9 +21,9 @@ int main(int argc, char* argv[]) ...@@ -20,9 +21,9 @@ int main(int argc, char* argv[])
Delete(&List, 6, &Elem); Delete(&List, 6, &Elem);
Delete(&List, 15, &Elem); // Illegal deletion of location. Deletion failed. Delete(&List, 15, &Elem); // Illegal deletion of location. Deletion failed.
for(i=0; i<List.nLength; i++) for (i=0; i<List.nLength; i++)
{ {
printf("%d ",List.Elements[i]); printf("%d ", List.Elements[i]);
} }
printf("\n"); printf("\n");
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论