uva 10878 - Decode the tape
#include<iostream>
#include<cctype>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
/*
每行'o'表示1,' '表示0,二进制转换为十进制是ASCII码
*/
int main(){
string s;
getline(cin,s);
while(getline(cin,s)){
if(s[0] == '_')
break;
int num = 0;
for(int i = 2; i< s.length() - 1; i++){
if(s[i] == 'o')
num = num * 2 + 1;
else if(s[i] == ' ')
num = num * 2;
}
cout << (char)num;
}
return 0;
}

浙公网安备 33010602011771号