UVa-10878-Decode the tape
AOAPC I: Beginning Algorithm Contests (Rujia Liu) :: Volume 1. Elementary Problem Solving :: String
// 10878 - Decode the tape #include <iostream> #include <cstring> using namespace std; int c[] = {0, 0, 64, 32, 16, 8, 0, 4, 2, 1, 0}; int main(void) { char s[20]; int i, len, value; cin.getline(s, 20); while(cin.getline(s, 20) && s[0]!='_') { value = 0; len = strlen(s); for(i=0; i<len; i++) if(s[i] == 'o') value += c[i]; cout << (char)value; } return 0; }