#include <stdlib.h>
#include <stdio.h>
#include <iostream>
using namespace std;
typedef struct node
{
char str;
struct node *next;
}List;
int main()
{
List *head,*p,*q,*temp;
head=(List *)malloc(sizeof(List));
int num;
while(cin>>num)
{
int i;
p=head;
for(i=0;i<num;i++)
{
q=(List *)malloc(sizeof(List));
cin>>q->str;
p->next=q;
p=q;
}
p->next=NULL;
temp=head;
temp=temp->next;
while(num>0)
{
i=0;
for(;i<num-1;i++)
{
temp=temp->next;
}cout<<temp->str<<" ";
temp=head->next;
num--;
}
}
return 0;
}
【数据结构_链表_List_0957】逆序输出链表
最新推荐文章于 2017-07-25 01:52:39 发布