UVA oj 490 Rotating Sentences(字符串)

原创 2016年06月02日 00:00:11
Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu

 Status

Description

Download as PDF

In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise. So instead of displaying the input sentences from left to right and top to bottom, your program will display them from top to bottom and right to left.

Input and Output

As input to your program, you will be given a maximum of 100 sentences, each not exceeding 100 characters long. Legal characters include: newline, space, any punctuation characters, digits, and lower case or upper case English letters. (NOTE: Tabs are not legal characters.)

The output of the program should have the last sentence printed out vertically in the leftmost column; the first sentence of the input would subsequently end up at the rightmost column.

Sample Input

Rene Decartes once said,
"I think, therefore I am."

Sample Output

"R
Ie
 n
te
h 
iD
ne
kc
,a
 r
tt
he
es
r
eo
fn
oc
re
e
 s
Ia
 i
ad
m,
.
"
这题就是把输入字符串顺时针旋转90度,没有字符的地方用空格补齐,不用文件的输入输出的话看不到测试结果
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

const int maxn = 105;
char a[maxn][maxn];

int main()
{
    int maxlen = -1;
    int i = 0;
    memset(a,0,sizeof(a));
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    while(gets(a[i]))
    {
        int len = strlen(a[i]);
        if(maxlen < len)
            maxlen = len;
        i++;
    }
    for(int j=0;j<maxlen;j++)
    {
        for(int k=i-1;k>=0;k--)
        {
            if(a[k][j] == 0)
                printf(" ");
            else
                printf("%c",a[k][j]);
        }
        printf("\n");
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

UVa - 490 - Rotating Sentences (AC)

In ``Rotating Sentences,'' you are asked to rotate a series of input sentences 90 degrees clockwise....

【UVA】【第0章】490 - Rotating Sentences

Rotating Sentences  In ``Rotating Sentences,'' you are asked to rotate a series of input ...

UVa--Rotating Sentences

Rotating Sentences  In ``Rotating Sentences,'' you are asked to rotate a series of input sentence...

Rotating Sentences

点击打开链接 fgets()函数的用法: 函数原型:char *fgets(char *buf, int bufsize, FILE *stream); 参数: *buf: 字符型指针,指向用来存储所...

UVA oj 445 Marvelous Mazes(水题字符串)

Marvelous Mazes Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %l...
  • Sara_YF
  • Sara_YF
  • 2016年06月02日 12:31
  • 154

Volume 0. Getting Started Uva10055, 10071,10300,458,494,490,414,445,488,489,694,457

刘汝佳 算法入门 第一版

UVA oj 489 Hangman Judge(字符串)

Hangman Judge Time Limit: 3000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu...
  • Sara_YF
  • Sara_YF
  • 2016年06月02日 15:51
  • 146

UVa490

490 - Rotating Sentences Time limit: 3.000 seconds Rotating Sentences In ``Rot...

uva 1453 Squares (旋转卡壳 rotating calipers)

reference: http://en.wikipedia.org/wiki/Rotating_calipers

OJ_整型字符串排序

  • 2015年05月16日 21:39
  • 2KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:UVA oj 490 Rotating Sentences(字符串)
举报原因:
原因补充:

(最多只允许输入30个字)