Thursday, November 26, 2015

UVa 11220 - Decoding the message.

// UVa 11220 - Decoding the message.

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

int main() {
	int tt;
	cin >> tt;
	string line;
	getline(cin, line);
	getline(cin, line);
	for (int t = 1; t <= tt; t++) {
		vector<string> sol;
		int n = 0;
		printf("Case #%d:\n", t);
		while (getline(cin, line) && line.length() > 0) {
			sol.push_back("");
			istringstream strm(line);
			string word;
			int i = 0;
			while (strm >> word) {
				if (word.length() > i)
					sol[n] = sol[n] + word[i++];
			}
			n++;
		}
		for (int j = 0; j < sol.size(); j++)
			cout << sol[j] << endl;
		if (t < tt)
			cout << endl;
	}
	return 0;
}

No comments:

Post a Comment