//比如输入的是abcd,输出应该是dcbabcd
#include
#include
struct Clist{
char data;
struct Clist *next;
struct Clist *pre;
};
typedef struct Clist *List;
void create(List &L){
L = (Clist*)malloc(sizeof(Clist));
L->next = NULL;
L->pre = NULL;
char ch;
for(int i = 0;i
scanf("%c",&ch);
Clist *q = (Clist*)malloc(sizeof(Clist));
q->data = ch;
q->next = L->next;
L->next->pre = q;
L->next = q;
q->pre = L;
}
}
void print(List &L){
Clist *s = L->next;
while(s->next){
printf("%c ",s->data);
s=s->next;
}
while(s->pre){
printf("%c ",s->data);
s=s->pre;
}
}
int main(){
Clist *head;
create(head);
print(head);
}