앗따 힘들다 ㅎ
package shape;
public class Snails {
public static void main(String args[]){
int a[][] = new int[5][5];
int k = 0;
int i = 0;
int j = -1;
int N = 5;
int sw = 1;
while(true){
for (int p = 0; p < N; p++) {
System.out.print("1");
k = k + 1;
j = j + sw;
System.out.println(j);
a[i][j] = k;
}
N = N - 1;
if (N <= 0) {
break;
}
System.out.println(j);
for (int p = 0; p < N; p++) {
System.out.print("2");
k = k + 1;
i = i + sw;
a[i][j] = k;
}
System.out.println(i);
sw = sw * (-1);
first = false;
}
System.out.println();
for (int l = 0; l < a.length; l++) {
for (int l2 = 0; l2 < a.length; l2++) {
System.out.print(a[l][l2]+" ");
}
System.out.println();
}
}
}