我倒,下面的程序怎么编译不了,大家编编,是不是我编译器累坏了
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
typedef struct node
{
int data;
struct node *nextPtr;
}*LinkList, Lnode; /* 链表结构 */
static void CreateList(LinkList *headPtr, LinkList *tailPtr, int item);
static void Reverse(LinkList *headPtr);
static void Traverse(LinkList headPtr);
int main(void)
{
LinkList headPtr = NULL, tailPtr = NULL;
int item;
printf("Enter item (0 quit): ");
scanf("%d", &item);
while (item != 0) /* 输入0退出循环 */
{
CreateList(&headPtr, &tailPtr, item);
pintf("Enter item (0 quit): ");
scanf("%d", &item);
}
Traverse(headPtr);
if (headPtr != NULL) /* 链表不空对链表进行逆序 */
{
Reverse(&headPtr);
Traverse(headPtr);
}
else
{
printf("list is empty.\n");
}
#endif
getch();
return 0;
}
/* 创建单链表函数 */
static void CreateList(LinkList *headPtr, LinkList *tailPtr, int item)
{
LinkList newPtr;
if ((newPtr = (LinkList)malloc(sizeof(Lnode))) == NULL)
{
exit(1);
}
newPtr -> data = item;
newPtr -> nextPtr = NULL;
if (*headPtr == NULL)
{
newPtr -> nextPtr = *headPtr;
*headPtr = newPtr;
}
else
{
(*tailPtr) -> nextPtr = newPtr;
}
*tailPtr = newPtr;
}
/* 单链表逆转函数 */
static void Reverse(LinkList *headPtr)
{
LinkList previousPtr, currentPtr, tempPtr;
previousPtr = NULL;
currentPtr = *headPtr; /* currentPtr 指向头结点*/
while (currentPtr != NULL) /* 逆序单链表的循环 */
{
tempPtr = currentPtr -> nextPtr;
currentPtr -> nextPtr = previousPtr;
previousPtr = currentPtr;
currentPtr = tempPtr;
}
}
/* 打印链表函数 */
static void Traverse(LinkList headPtr)
{
while (headPtr != NULL)
{
printf("%d -> ", headPtr -> data);
headPtr = headPtr -> nextPtr;
}
printf("NULL\n");
}