c语言中利用对象宏式对数组元素进行倒序排列
1、
#include <stdio.h> #define NUMBER 5 int main(void) { int a[NUMBER]; int i; puts("please input several numbers."); for (i = 0; i < NUMBER; i++) { printf("%dst = ", i + 1); scanf("%d", &a[i]); } puts("----- ----- -----"); int temp; for (i = 0; i < NUMBER/2; i++) { temp = a[i]; a[i] = a[NUMBER-1-i]; a[NUMBER-1-i] = temp; } for (i = 0; i < NUMBER; i++) printf("a[%d] = %d ", i, a[i]); return 0; }