[백준] C# : 10811번(바구니 뒤집기)

Jag·2023년 7월 17일
0

Baekjoon

목록 보기
9/12
post-thumbnail
using System;

namespace BaekjoonTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split();

            int n = int.Parse(nm[0]);
            int m = int.Parse(nm[1]);

            int[] N = new int[n];

            int i;
            int temp;
            for(i = 0; i < N.Length; i++)
            {
                N[i] = i + 1;
            }
            for(i = 0; i<m; i++)
            {
                string[] ab = Console.ReadLine().Split();
                int a = int.Parse(ab[0])-1;
                int b = int.Parse(ab[1])-1;

                while (a < b)
                {
                    temp = N[a];
                    N[a++] = N[b];
                    N[b--] = temp;
                }
            }
            for(i = 0; i < N.Length; i++)
            {
                Console.Write(N[i] + " ");
            }
        }
    }
}

출력 조건에 유의하자.. 띄어쓰기 때문에 6번이나 고쳤다.........

profile
C# Unity Engineer

1개의 댓글

comment-user-thumbnail
2023년 7월 17일

저도 개발자인데 같이 교류 많이 해봐요 ㅎㅎ! 서로 화이팅합시다!

답글 달기