Decode the tape

来源:互联网 发布:淘宝怎么开好店 编辑:程序博客网 时间:2024/04/28 18:22
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <map>


using namespace std;


char s[20];
string str;


int num[] = {0, 128, 64, 32, 16, 8, 0, 4, 2, 1};
int main()
{
    bool flag = false;
    char head[] = "___________";
    while(gets(s))
    {
        if(!flag && !strcmp(s,head))
        {
            flag = true;
            str.clear();
            continue;
        }


        if(flag && !strcmp(s, head))
        {
            cout<<str;
            flag = false;
            break;
        }
       int sum = 0;
       for( int i = 1; i <= 9; i++)
          if(s[i] == 'o')
            sum += num[i];
        str += char(sum);


    }
    return 0;
}
0 0
原创粉丝点击