문제
당신은 길을 가다가 이상한 쪽지를 발견했다. 그 쪽지에는 암호가 적혀 있었는데, 똑똑한 당신은 암호가 뒤집으면 해독된다는 것을 발견했다.
이 암호를 해독하는 프로그램을 작성하시오.
입력
한 줄에 하나의 암호가 주어진다. 암호의 길이는 500을 넘지 않는다.
마지막 줄에는 "END"가 주어진다. (END는 해독하지 않는다.)
출력
각 암호가 해독된 것을 한 줄에 하나씩 출력한다.
예제 입력 1
!edoc doog a tahW noitacitsufbo erafraw enirambus detcirtsernu yraurbeF fo tsrif eht no nigeb ot dnetni eW lla sees rodroM fo drol eht ,ssertrof sih nihtiw delaecnoC END |
예제 출력 1
What a good code! obfustication We intend to begin on the first of February unrestricted submarine warfare Concealed within his fortress, the lord of Mordor sees all |
더보기
Solution
#include<stdio.h>
#include<string.h>
int main(void)
{
while(1)
{
char note[501]={'\0', };
fgets(note,sizeof(note),stdin);
note[strlen(note)-1]='\0';
if(strcmp(note,"END")==0)
break;
for(int i=strlen(note)-1;i>=0;i--)
printf("%c", note[i]);
printf("\n");
}
return 0;
}
728x90
'백준 알고리즘' 카테고리의 다른 글
<백준 알고리즘> 16394번: 홍익대학교 (0) | 2020.09.26 |
---|---|
<백준 알고리즘> 14730번: 謎紛芥索紀 (Small) (0) | 2020.09.26 |
<백준 알고리즘> 10874번: 이교수님의 시험 (0) | 2020.09.26 |
<백준 알고리즘> 10419번: 지각 (0) | 2020.09.26 |
<백준 알고리즘> 1357번: 뒤집힌 덧셈 (0) | 2020.09.25 |