UVA – 490 – Rotating Sequences

#include <iostream>
#include <string.h>
#include <string>
#include <algorithm>
using namespace std;
#define MAX 105

string g[MAX];

int main() {
	int I = 0, j = 0, i = 0,MX=0;
	while (getline(cin, g[I])) MX = max(MX, (signed)g[I++].size());
	for (j = 0; j < MX; j++) {
		for (i = I - 1; i >= 0; i--) {
			if (j >= g[i].size())	cout << ' ';
			else					cout << g[i][j];
		}
		cout << endl;
	}
	return 0;
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: