#include <iostream>
#include <malloc.h>
using namespace std;
struct biao
{
int data;
struct biao *next;
};
void shu_ru(struct biao *head,int n)
{
for(int i=1; i<=n; i++)
{
struct biao *p=(struct biao *)malloc(sizeof(struct biao));
cin>>p->data;
p->next=head->next;
head->next=p;
}
}
void shu_chu(struct biao *head)
{
cout<<head->next->data;free(head);
head=head->next;
while(head->next)
{
cout<<" "<<head->next->data;
head=head->next;
free(head);
}
}
int main(void)
{
struct biao *head=NULL;
head=(struct biao *)malloc(sizeof(struct biao));
head->next=NULL;
int t;
cin>>t;
shu_ru(head,t);
shu_chu(head);
return 0;
}
/**************************************
Problem id : SDUT OJ 2117
User name : 李俊
Result : Accepted
Take Memory : 464K
Take Time : 0MS
Submit Time : 2013-12-09 21:45:23
**************************************/原文地址:http://blog.csdn.net/li_jun_09_05/article/details/26971911