• Home
  • About
    • back
    • changsoooooo's Blog photo

      changsoooooo's Blog

      changsoooooo's Blog.

    • Learn More
    • Twitter
    • Facebook
    • Instagram
    • Github
    • Steam
  • 일상
  • 교육
    • back
    • 교육학
    • 정보 컴퓨터 교육
    • 임용
  • 개발
  • 잡지식
  • 한국사
  • Projects

10804(카드역배치)

08 Nov 2020

Reading time ~1 minute

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
//카드 역배치 10804
using namespace std;
int main(){
	ios::sync_with_stdio(0); 
	cin.tie(0);
	
	int arr[21];
	for (size_t i = 1; i <= 20; i++)
	{
		arr[i]=i;
	}
	for (size_t k = 0; k < 10; k++)
	{
		int a, b;
		cin >> a >> b;
		
		for (size_t i = 0; i < (b - a + 1) / 2; i++)
		{
			int temp;
			temp = arr[b - i];
			arr[b - i] = arr[a + i];
			arr[a + i] = temp;
			
		}
	}
	for (size_t i = 1; i <= 20; i++)
	{
		cout << arr[i] << ' ';
	}
}


Share Tweet +1