Thursday, December 21, 2017

490 - Rotating Sentences Uva Solution & Logic

//
*Very Interesting Problem , Just Think Differently.
*In Output , One Line can be extended upto maximum length of given string
*Print From The Last
///

See Code .............


#include<bits/stdc++.h>

// Nayeem Shahriar Joy , Applied Physics & Electronic Engineering , University of Rajshahi.

using namespace std;




int main() {
    int mx_length = 0;
    string s;
    vector<string> str;
    while(getline(cin, s)) {
        str.push_back(s);
        mx_length = max(mx_length, (int) s.length());
    }
    for(int i = 0; i < mx_length; i++) {
        for(int j = str.size() - 1; j >= 0; j--) {
                if(i<str[j].length())
                {
                    printf("%c",str[j][i]);
                }
                else{
                        char c=' ';
                    printf("%c",c);
                }
        } printf("\n");
    }
    return 0;
}

No comments:

Post a Comment