2차원 배열모래시계입니다. 별거 아니에요 ㅎ
package shape;
public class SandWatch {
public static void main(String[] args) {
int a[][] = new int[5][5];
int k = 0;
int row = 0;
int center = 5/2 + 1;
int begin = 0;
int end = 0;
for (row = 0; row < 5; row++) {
if (row < center) {
System.out.println("up");
begin = row;
end = 5 - row;
}else{
System.out.println("down");
begin = 4 - row;
end = row + 1;
}
for (int j = begin; j < end; j++) {
k = k + 1;
a[row][j] = k;
}
}
for (int i = 0; i < 5; i++) {
for (int j = 0; j < 5; j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
}