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

modify

上级 2e9ad80f
#ifndef SINGLELINKLIST_H_
#define SINGLELINKLIST_H_
//
// Include the C standard library header file here
//
#include <stdio.h>
//
// Other header files are included here
//
//
// Define the data structure here
//
typedef int ElemType; // The type of an element in a linked list
typedef struct Node {
typedef struct Node
{
ElemType data; // Data fields
struct Node* next; // pointer field
}LinkList;
//
// Declare the function here
//
int Delete(LinkList* pListHead, int i, ElemType* pElem);
#endif /* SINGLELINKLIST_H_ */
#include "SingleLinkList.h"
#include <stdlib.h>
int main(int argc, char* argv[])
{
......@@ -18,7 +18,7 @@ int main(int argc, char* argv[])
//
// Initializes the nodes of a single list
//
for(i=8; i>0; i--)
for (i=8; i>0; i--)
{
pListNode = (LinkList*)malloc(sizeof(LinkList));
pListNode->data = i;
......@@ -34,7 +34,7 @@ int main(int argc, char* argv[])
Delete(pListHead, 20, &Elem); // Illegal deletion of location. Deletion failed.
pListHeadTemp = pListHead;
while(pListHeadTemp->next != NULL)
while (pListHeadTemp->next != NULL)
{
pListNode = pListHeadTemp->next;
printf("%d ", pListNode->data);
......@@ -45,7 +45,7 @@ int main(int argc, char* argv[])
//
// Destroy single linked list
//
while(pListHead->next != NULL)
while (pListHead->next != NULL)
{
pListNode = pListHead->next;
pListHead->next = pListNode->next;
......
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论