赞
踩
1
2
3
|
10
ABCDEFGHIJ
|
1
2
|
J I H G F E D C B A
|
- #include <iostream>
- #include <malloc.h>
- using namespace std;
-
- typedef struct node{
- char data;
- struct node *next;
- }LinkList;
-
- int main(){
- int n;
- cin>>n;
- LinkList *l,*body;
- l=(LinkList*)malloc(sizeof(LinkList));
- l->next=NULL;
- char ch;
- for(int i=0;i<n;i++){
- cin>>ch;
- body=(LinkList*)malloc(sizeof(LinkList));
- body->data=ch;
- body->next=l->next;
- l->next=body;
- }
- LinkList *head=l->next;
- while (head->next!=NULL) {
- cout<<head->data<<' ';
- head=head->next;
- }
- cout<<head->data<<' ';
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。