추가 '숫자놀이'
This commit is contained in:
parent
ad611a2f19
commit
394fc0b86e
|
|
@ -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
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue