Sunday, February 27, 2011

490 - Rotating Sentences


#include<iostream>
#include<cstring>
#include<stdio.h>
using namespace std;
char sen[100][101];
int main()
{
    int i=0,j=0,n=0,max=0,l;
    //freopen("in.txt","r",stdin);
    while(gets(sen[n]))n++;
    for(i=0;i<n;i++)
    {
        l=strlen(sen[i]);
        if(max<l)max=l;
        for(j=l;j<100;j++)
            sen[i][j]=' ';
        sen[i][100]='\0';
    }
    for(j=0;j<max;j++)
    {
        for(i=n-1;i>=0;i--)
            cout<<sen[i][j];
        cout<<endl;
    }
    exit(0);
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.