#include <iostream>
#include <cstdlib>
using namespace std;
typedef struct node
{
int data;
pNODE next;
}NODE, * pNODE;
int main()
{
pNODE head, p, q, t;
int a, i, n;
cin >> n;
head = NULL;
for (i = 1; i <= n; i++)
{
cin >> a;
p = (pNODE)malloc(sizeof(NODE));
p->data = a;
p->next = NULL;
if (head == NULL)
head = p;
else
q->next = p;
q = p;
}
t = head;
while (t != NULL)
{
cout << t->data;
t = t->next;
}
free(p);
system("pause");
return 0;
}
不能用pNode,用struct node *next
第9行:pNODE next; 修改为:struct node *next;
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!