#include <stdio.h> //#include <stdlib.h>
/*int *fun() { //int *p = (int *)malloc(sizeof(int)); int a; int *p = &a; *p = 12; return p; }*/
void invert(int *array, int n) { int *i, *j, temp; i = array; j = array + n - 1; while (i < j) { temp = *i; *i = *j; *j = temp; i++; j--; } }
void main() { /*int a[] = {15, -27, 63, 49, 115, 663, 774}; int *const p = &a[2]; printf("%d\n", (*p)++); printf("%d\n", *p);*/
/* int *p2 = fun(); int *p3; *p2 += 2; p3 = fun(); printf("%d\n", *p3); printf("%d\n", *p2);*/ //free(p2); //free(p3);
int a[] = {2, 4, 7, 3, 6, 9, 11, 14, 8}; int len = sizeof(a) / sizeof(int); int i; for (i = 0; i < len; i++) printf("%-3d", *(a + i)); printf("\n");
invert(a, 4); for (i = 0; i < len; i++) printf("%-3d", *(a + i)); printf("\n"); }
|