42 lines
734 B
Plaintext
42 lines
734 B
Plaintext
|
|
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
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|