int printf(char* format, ...); int scanf(char* format, ...); int exit(int status); void assert_eq(int expected, int actual) { if (expected != actual) { printf("expected: %d, actual: %d\n", expected, actual); exit(1); } } void swap(int* a, int* b) { int t = *a; *a = *b; *b = t; } void sort(int a[], int n) { for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (a[i] > a[j]) { swap(&a[i], &a[j]); assert_eq(i - j, &a[i] - &a[j]); assert_eq(j - i, &a[j] - &a[i]); assert_eq(a[i], *(a + i)); assert_eq(i[a], *(i + a)); assert_eq(a[j - i], *(a + (j - i))); assert_eq(j[a - i], *(j + (a - i))); } } } } int a[100]; int n; int main() { scanf("%d", &n); for (int i = 0; i < n; i++) { scanf("%d", &a[i]); } sort(a, n); for (int i = 0; i < n; i++) { printf("%d ", a[i]); } printf("\n"); }