/* ACM North Central Region, 1994-95 Problem A, Mapping the Swaps Ed Karrels, May 1996 */ #include #include void swap(int *a, int i) { int t; t = a[i]; a[i] = a[i+1]; a[i+1] = t; } int bub_srt(int n, int b[]) { int *a, ns=0, i, j; a = (int*)malloc(sizeof(int) * n); for (i=0; i0; i--) { for (j=0; j a[j+1]) { swap(a, j); ns++; } } } return ns; } int try(int n, int *a, int depth) { int i, ns=0; if (!depth) { for (i=0; i a[i+1]) return 0; } return 1; } for (i=0; i