Sample Output
12 56 4 6 55 15 33 62
Hint
不得使用数组!
#include <iostream>
#include"cstdio"
#include"cstring"
#include"cstdlib"
using namespace std;
struct gsd
{
int num;
gsd *next;
}*head;
int main()
{
gsd *p,*q;
head=(gsd*)malloc(sizeof(gsd));
head->next=NULL;
p=head;
int n;
scanf("%d",&n);
while(n--)
{
q=(gsd*)malloc(sizeof(gsd));
scanf("%d",&q->num);
p->next=q;
p=q;
}
p->next=NULL;
p=head->next;
while(p->next!=NULL)
{printf("%d ",p->num);
q=p->next;
p=q;
}
printf("%d\n",p->num);
return 0;
}