#include #define N 6 int main() { int data[N]; /* 配列の宣言 */ int tmp; int *p, *q, *max_ptr; printf("Please input %d numbers\n", N); for(p = data; p < data + N; p++) scanf("%d", p); for(p = data; p < data + N - 1; p++){ max_ptr = p; for(q = p + 1; q < data + N; q++){ if(*q > *max_ptr) max_ptr = q; } tmp = *p; *p = *max_ptr; *max_ptr = tmp; } printf("Sorted data from highest to lowest\n"); for(p = data; p < data + N; p++) { printf("%d ", *p); } printf("\n"); return 0; }