diff --git a/숫자놀이 b/숫자놀이 new file mode 100644 index 0000000..150acf4 --- /dev/null +++ b/숫자놀이 @@ -0,0 +1,41 @@ +package AlgorythmTest; + +import java.util.Scanner; + +public class AlgorythmTest1 { + + public static void main(String[] args) { + + Scanner s = new Scanner(System.in); + System.out.println("써 : "); + int num = Integer.parseInt(s.nextLine()); + + int a = 1; + int check = 0; + int[][] list = new int[num][num]; + + for (int k = 0; k < num; k++) { + for (int i = 0; i < num; i++) { + list[k][i] = a; + a++; + System.out.print(list[k][i] + " "); + } + } + + System.out.println(""); + + int x = num - 1; + + for (int j = 0; j < num; j++) { + for (int m = 0; m < num; m++) { + if (j % 2 == 0) + System.out.print(list[j][x--] + " "); + else if (j % 2 == 1) + System.out.print(list[j][++x] + " "); + + } // 321 456 987 + } + + } + +}