ACM준비/algospot

EDIAN

조규현15 2015. 8. 4. 09:32
반응형

https://www.algospot.com/judge/problem/read/ENDIANS

 

algospot.com :: ENDIANS

Endians 문제 정보 문제 The two island nations Lilliput and Blefuscu are severe rivals. They dislike each other a lot, and the most important reason was that they break open boiled eggs in different ways. People from Lilliput are called little-endians

www.algospot.com

Edian간의 보간을 하는 문제임.

8bit( 1 Byte )가 최소단위임을 고려하여 bit연산으로 해결함.

#include 

int main()
{
	int CASE;
	for (scanf("%d", &CASE); CASE > 0; CASE--)
	{
		unsigned int INPUT = 0;
		unsigned int OUTPUT = 0;
		int MASK = 0xFF;
		scanf("%u", &INPUT);

		for (int i = 3; i >= 0; i--)
		{
			OUTPUT |= ((INPUT & MASK) << (8*i));
			INPUT = INPUT >> 8;
		}
		printf("%u\n", OUTPUT);
	}
	return 0;
}
반응형

'ACM준비 > algospot' 카테고리의 다른 글

ZEROONE  (0) 2015.08.05
KBODRAFT  (0) 2015.08.05
GRIDISLANDS - 2  (0) 2015.07.30
GRIDISLANDS  (0) 2015.07.30
BRACKETS  (0) 2015.07.30