C#...
int input_number = 7;
for (int i = 0; i < input_number; i++)
{
values[i] = new int[7];
}
int adding = 1;
int x = 0;
int y = 0;
int roll = 5;
int x_max = input_number;
int y_max = input_number;
int x_min = 0;
int y_min = 0;
while (true) {
for (; x < x_max; x++)
{
values[y][x] = adding++;
}
x--;
y++;
for (; y < y_max; y++)
{
values[y][x] = adding++;
}
y--;
x--;
for (; x > x_min; x--)
{
values[y][x] = adding++;
}
for (; y > y_min; y--)
{
values[y][x] = adding++;
}
x++;
y++;
x_max--;
y_max--;
x_min++;
y_min++;
roll--;
if (roll==0)
{
break;
}
}
for (int i = 0; i < input_number; i++)
{
for (int j = 0; j < input_number; j++)
{
Console.Write(values[i][j] + "\t");
}
Console.WriteLine();
}
어머.. 넘나 멋진것^^
답글삭제