UVA 490 - Rotating Sentences

题意:将所给字符串顺时针旋转90度输出,水题,直接上代码
代码如下:

#include <bits/stdc++.h>

using namespace std;
char x[105][105];
int main()
{
    int i=0,Max=0,Long,n;
    memset(x,0,sizeof(x));
    while(cin.getline(x[i],105))
    {
        n=strlen(x[i++]);
        Max=max(Max,n);
    }
    Long=i-1;
    for(i=0; i<Max; ++i)
    {
        for(int j=Long; j+1; j--)
        {
            if(x[j][i])
                cout<<x[j][i];
            else
                cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}

猜你喜欢

转载自blog.csdn.net/liuxinyu666/article/details/80203197