추가 '숫자놀이'

This commit is contained in:
kim_yubin 2018-12-23 20:04:39 +09:00
parent ad611a2f19
commit 394fc0b86e
1 changed files with 41 additions and 0 deletions

41
숫자놀이 Normal file
View File

@ -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
}
}
}