final int N = 15; void bottles(int n) { if (n < 10) System.out.print(" " + n + " bottle"); else System.out.print(n + " bottle"); if (n != 1) System.out.print("s"); System.out.println(" of beer on the wall."); } void f(int n) { while (n > 0) { bottles(n); n--; } } | #define N 15 void bottles(int n) { printf("%2i bottle", n); if (n != 1) printf("s"); printf(" of beer on the wall.\n"); } void f(int n) { while (n > 0) { bottles(n); n--; } } |
int partition(int[] A, int p, int r) { int x = A[r]; int i = p - 1; for (int j = p; j < r; j++) { if (A[j] <= x) { i++; exchange(A,i, j); } } exchange(A, i+1, r); return i + 1; } | Partition(A, p, r) |