#include<stdio.h>
#include<stdlib.h>
struct List{
int data;
struct List *next;
};
void set_list(struct List *p,int n){
int i=1;
struct List *p1 = NULL;
p1 = (struct List *)malloc(sizeof(struct List));
p->next = p1;
p1->next = NULL;
scanf("%d",&(p1->data));
while(n-1){
set_list(p1, n-1);
break;
}
}
int main(){
int n,m;
scanf("%d",&n);
struct List *head = NULL;
head = (struct List*)malloc(sizeof(struct List));
set_list(head, n);
struct List *p = head->next;
int temp;
temp = p->data;
p->data = p->next->data;
p->next->data = temp;
p = head;
for(int i=1;i<=n-1;i++){
p = p->next;
if(i==n-1){
temp = p->data;
p->data = p->next->data;
p->next->data = temp;
break;
}
}
p = head->next;
for(int i=0;i<n;i++){
printf("%d ",p->data);
p=p->next;
}
return 0;
}
#include<stdlib.h>
struct List{
int data;
struct List *next;
};
void set_list(struct List *p,int n){
int i=1;
struct List *p1 = NULL;
p1 = (struct List *)malloc(sizeof(struct List));
p->next = p1;
p1->next = NULL;
scanf("%d",&(p1->data));
while(n-1){
set_list(p1, n-1);
break;
}
}
int main(){
int n,m;
scanf("%d",&n);
struct List *head = NULL;
head = (struct List*)malloc(sizeof(struct List));
set_list(head, n);
struct List *p = head->next;
int temp;
temp = p->data;
p->data = p->next->data;
p->next->data = temp;
p = head;
for(int i=1;i<=n-1;i++){
p = p->next;
if(i==n-1){
temp = p->data;
p->data = p->next->data;
p->next->data = temp;
break;
}
}
p = head->next;
for(int i=0;i<n;i++){
printf("%d ",p->data);
p=p->next;
}
return 0;
}