과제 호우
c# 구현
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
class Program
{
static void Main(string[] args)
{
int n = 4;
int num = n * n;
int x =0, y = 0 ;
int[][] Rarray = new int[n][];
for (int i = 0; i < n; i++)
{
Rarray[i] = new int[n];
}
for (int j = n - 1; j > 0 ; j-=2)
{
for (int a = 0; a < 4; a++)
{
for (int i = 0; i < j; i++)
{
switch (a)
{
case 0:
Rarray[y][x] = num;
x++;
num--;
break;
case 1:
Rarray[y][x] = num;
y++;
num--;
break;
case 2:
Rarray[y][x] = num;
x--;
num--;
break;
case 3:
Rarray[y][x] = num;
y--;
num--;
break;
default:
break;
}
}
}
x++;
y++;
}
if ((n%2) == 1)
{
Rarray[y][x] = 1;
}
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
Console.Write($"{Rarray[i][j],2}");
}
Console.WriteLine("");
}
}
}
}
'공부,일 > 셸 스크립트' 카테고리의 다른 글
20210622셀스크립트 실습 (0) | 2021.06.22 |
---|---|
쉘스크립트 실습 20210621 (0) | 2021.06.21 |
20210618 (0) | 2021.06.18 |
shell scrip 권한 읽고 수정하는 방법 (0) | 2021.06.18 |
winscp (0) | 2021.06.18 |
댓글