/* 3. 다음 프로그램의 출력을 써라. */ #include <string.h> #include <stdio.h> void swap(int x,int &y) { int t = x; x = y; y = t; } void What(int *a,int row,int col) { int n = row*col - 1; for(int i=0; i<n; i=i+2) { swap(a[i],a[i+1]); } } void main() { char data[10]; strcpy(data,"2011810"); int count = 0; int array[3][3]; for (int i=0; i<3; i++) { for(int j=0; j<3; j++) { if (count > 6) { array[i][j] = 1; } else { array[i][j] = data[count] - '0'; } count++; } } What((int*)array,3,3); for (i=0; i<3; i++) { for(int j=0; j<3; j++) { printf("%d ",array[i][j]); } printf("\n"); } }