UVA490 Rotating Sentences 字符串输入输出处理

In “Rotating Sentences,” you are asked to rotate a series of input sentences 90 degrees clockwise. Soinstead of displaying the input sentences from left to right and top to bottom, your program will displaythem from top to bottom and right to left.

Input

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

Output

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<bits/stdc++.h>
using namespace std;
int main()
{
	char a[222][222]={0};
	int maxx=0;
	int i=0;
	while(gets(a[i])!=NULL)
	{
		if(strlen(a[i])>maxx)maxx=strlen(a[i]);
		i++;
		
		
	}
//	cout<<i;
/*	for(int w=0;w<50;w++)
	{
		for(int e=0;e<50;e++)cout<<a[w][e];	
		cout<<endl;
	}*/
//	cout<<a[0]<<endl<<a[1];

	for(int j=0;j<maxx;j++)
	for(int k=i-1;k>=0;k--)
	{
		if(a[k][j]==0)cout<<" ";
		else cout<<a[k][j];
		if(!k)cout<<endl;
	}
	
	return 0;
}

如果是二位数组a[10][10] , a[0]指的是第一行一整行;

以后读字符串可以这样写:

while(gets(a[i])!=NULL)


In “Rotating Sentences,” you are asked to rotate a series of input sentences 90 degrees clockwise. Soinstead of displaying the input sentences from left to right and top to bottom, your program will displaythem from top to bottom and right to left.

Input

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

Output

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,

.

"


问题链接UVA490 Rotating Sentences

题意简述

  输入若干行字符串,将其旋转90度后输出。

问题分析

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值