怎么理解x[i]?是数组呢?还是指针下标
程序代码:
void scott(int *x, int n) { int i, j, m, t; for (i = 0; i < n - 1; i++) { m = i; for (j = i + 1; j < n; j++) if (x[j] > x[m]) m = j; if (m != i) { t = x[i]; x[i] = x[m]; x[m] = t; } } }
void scott(int *x, int n) { int i, j, m, t; for (i = 0; i < n - 1; i++) { m = i; for (j = i + 1; j < n; j++) if (x[j] > x[m]) m = j; if (m != i) { t = x[i]; x[i] = x[m]; x[m] = t; } } } #include<stdio.h> int main() { void scott(int *x, int n); int a[10] = { 0,1,2,3,4,5,6,7,8,9 }; int *p; int i; p = a; scott(p, 10); for (p = a, i = 0; i < 10; i++) printf("%d ", *p++); printf("\n"); return 0; }