还是指向指针的指针
程序代码:
#include<stdio.h> void scanf_num(int *a[], int n) { int i; int *p; p = a[0]; for (i = 0; i < n; i++, p++) scanf_s("%d", p); } void sort_num(int *a[], int n) { int i, m = 0, h = 0, *t, *v; int **p; p = a; for (i = 0; i < n; i++) { if (p[m] > p[i]) m = i; if (p[h] < p[i]) h = i; } if (m != 0) { t = p[0]; p[0] = p[m]; p[m] = t; } if (h == 0) h = m; if (h != n - 1) { v = p[h]; p[h] = p[n - 1]; p[n - 1] = v; } } void print_num(int *a[], int n) { int i; int *p; p = a[0]; for (i = 0; i < n; i++, p++) printf("%d%c", *p, i < n - 1 ? ' ' : '\n'); } int main() { void scanf_num(int *a[], int n); void sort_num(int *a[], int n); void print_num(int *a[], int n); int x[10], *a[10]; int i; for (i = 0; i < 10; i++) a[i] = &x[i]; scanf_num(a, 10); sort_num(a, 10); print_num(a, 10); return 0; }