MagicSquare03

IT 잡다/sorcecode 2015. 4. 19. 23:52

package algorithm;


public class MagicSquare03 {


public static void main(String[] args) {


int[][] arrayListA = new int[5][5];

int i = 0;

int j = 2;

int k = 0;


do {

k = k + 1;

arrayListA[i][j] = k;

if (k % 5 == 0) {

i = i + 1;

} else {


i = i - 1;

j = j + 1;


if (i < 0) {

i = 4;

}


if (j > 4) {

j = 0;

}


}

} while (k > 25);


// 출력

System.out.println(arrayListA[0][2]);


for (int n = 0; n < 5; n++) {

for (int m = 0; m < 5; m++) {

System.out.print(arrayListA[n][m] + " ");

}

System.out.println();

}


}


}



'IT 잡다 > sorcecode' 카테고리의 다른 글

ㄹ 자 채우기  (0) 2015.05.04
magicSquare02-마방진 소스  (0) 2015.04.30
7장 연습문제  (0) 2015.04.07
7장 연습문제 19 re  (0) 2015.04.07
wordScramble2  (0) 2015.04.06
Posted by 파란개발자
,