Advertisement
Pabon_SEC

Decode the tape

Apr 4th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. char str[15];
  6.  
  7. int main()
  8. {
  9.     gets(str);
  10.  
  11.     while(gets(str))
  12.     {
  13.  
  14.         if(strcmp(str,"___________")==0)
  15.             break;
  16.  
  17.         int len = strlen(str);
  18.  
  19.         int res = 0;
  20.  
  21.         for(int i=0; i<len; i++)
  22.         {
  23.             if(str[i]==' ')
  24.             {
  25.                 res *=2;
  26.             }
  27.             else if(str[i]=='o')
  28.             {
  29.                 res = res*2+1;
  30.             }
  31.         }
  32.  
  33.         printf("%c",res);
  34.     }
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement