#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
void sort(int* array, int n) ;
typedef struct list {
int number;
struct list* behind;
} list;
void InitList (list* ptr);
int main() {
int n, i;
scanf("%d", &n); /*输入数组长度*/
getchar();
if (n == 0) { /*判断数组长度是否合理*/
return -1;
}
int array[100] = { 0 }; /*定义数组*/
int* p = array; /*定义指针*/
for (i = 0; i < n; i++) { /*输入n个正整数*/
scanf("%d", array + i);
getchar();
}
//sort(array, n);
list* head = NULL;
list* link = NULL;
int k;
for (k = 0; k < n; k++) {
list* alloc = (list*)malloc(sizeof(list));
alloc->number = array[k];
alloc->behind = NULL;
if (head == NULL) {
head = alloc;
link = alloc;
} else {
link->behind = alloc;
link = link->behind;
}
}
//头部替换
list* temp = head->behind;
head->behind = temp->behind;
temp->behind = head;
head = temp;
//尾部替换
list* A = NULL;
list* B = NULL;
list* C = head;
while (C->behind != NULL) {
A = B;
B = C;
C = C->behind;
}
if (A!=NULL)
{
C->behind=B;
A->behind=C;
B->behind=NULL;
}
while (head != NULL) {
printf("%d ", head->number);
head = head->behind;
}
// for (i = 0; i < n; i++) {
// printf("%d ", array[i]);
// }
return 0;
}