#include <stdlib.h>
#include <time.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
void swap(int *p, int *q) {
int tmp = *p;
*q = *p;
*p = tmp;
}
void fun(int n, int *array) {
static int i = 0;
static int j = (i + 1) % n;
swap(array[i], array[j]);
i = (i + 1) % n;
j = (i + 1) % n;
}
int main() {
srand(time(NULL));
int n = 10;
int array[100] = {0};
for (int i = 0;i < n;i++) {
array[i] = i + 1;
}
for (int i = 0;i < 10;i++) {
fun(n, array);
for (int i = 0;i < n;i++) {
cout << array[i] << " ";
}
cout << endl;
}
return 0;
}