반응형
    
    
    
  문제 출처 :
https://www.acmicpc.net/problem/12174
알고리즘 분석 :
문제 해결에 필요한 사항
1. 구현
O와 I를 8개로 끊어 I가 나올 때 마다 해당하는 바이너리 값을 넣어주고 그에 맞는 char형을 출력하면 된다.
구현 문제이고 코딩을 완성하게되면 출력되는 결과물이 신기한 문제이다.
소스 코드 :
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #include <iostream> #include <cstdio> #include <string> using namespace std; int main() {     int tc;     int binary[8] = { 1,2,4,8,16,32,64,128 };     scanf("%d", &tc);     for(int t = 1 ; t <= tc ; t ++)     {         int n;         scanf("%d", &n);         getchar();         printf("Case #%d: ", t);         for(int i = 0 ; i < n ; i ++)         {             int val = 0;             for (int j = 7; j >= 0; j--)             {                 char ch;                 scanf("%c", &ch);                 if (ch == 'I')                     val += binary[j];             }             printf("%c", (char)val);         }         printf("\n");     }     return 0; } //                                                       This source code Copyright belongs to Crocus //                                                        If you want to see more? click here >> | Crocus | 
반응형
    
    
    
  'Applied > 알고리즘 문제풀이' 카테고리의 다른 글
| [1949번] 등산로 조성 (0) | 2019.06.11 | 
|---|---|
| [1265번] 달란트2 (0) | 2019.06.10 | 
| [1244번] 최대 상금 (2) | 2019.06.05 | 
| [SwExpertAcademy] 평등주의 (0) | 2019.06.04 | 
| [Codeground 11번] 개구리 뛰기 (0) | 2019.06.03 |