#include <stdio.h>
#define SIZE 5
void func(int *, int);
int main(void){
int ary[SIZE]={1,7,3,9,5}; //SIZE=5, ary[5]
func(ary, SIZE); //func(ary, 5);
printf("%d %d", *(ary), ary[SIZE-2]);
//ary는 첫 번째 원소 가리킴. *(ary)=5
//ary[3]=7
//5 7 출력
return 0;
}
void func(int *pa, int n){ //func(*pa=ary, n=5);
int i, temp;
for(i=0; i<n/2; i++){ // 5/2=2 i=0,1
temp = *(pa+i);
pa[i]=pa[n-1-i];
pa[n-1-i]=temp;
//pa[i]와 pa[5-1-i]=pa[4-i] swap 자리 바꾸기!
//pa[0]와 pa[4] swap
//pa[1]와 pa[3] swap
//ary[5]={5,9,3,7,1};
}
}
To embed this project on your website, copy the following code and paste it into your website's HTML: