Monday, October 5, 2015

UVa 10878 - Decode the tape

// UVa 10878 - Decode the tape

#include <iostream>
#include <stdio.h>
using namespace std;

char p[8] = { 1, 2, 4, 8, 16, 32, 64, 128 };

int main() {
	string l;
	getline(cin, l);
	getline(cin, l);
	while (l[0] == '|') {
		char num = 0;
		for (int i = 1; i <= 5; i++) {
			if (l[i] == 'o')
				num += p[8 - i];
		}
		for (int i = 7; i <= 9; i++)
			if (l[i] == 'o')
				num += p[9 - i];
		printf("%c", num);
		getline(cin, l);
	}
	return 0;
}

No comments:

Post a Comment