UVA490 Rotating Sentences 字符串输入输出处理
2018-03-27 20:17
771 查看
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.InputAs 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.)OutputThe 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 InputRene Decartes once said,"I think, therefore I am."Sample Output"RIentehiDnekc,arttheesreofnocreesIaiadm,."题意简述: 输入若干行字符串,将其旋转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.InputAs 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.)OutputThe 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 InputRene Decartes once said,"I think, therefore I am."Sample Output"RIentehiDnekc,arttheesreofnocreesIaiadm,."
问题链接:UVA490 Rotating Sentences。题意简述: 输入若干行字符串,将其旋转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.InputAs 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.)OutputThe 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 InputRene Decartes once said,"I think, therefore I am."Sample Output"RIentehiDnekc,arttheesreofnocreesIaiadm,."
问题链接:UVA490 Rotating Sentences。题意简述: 输入若干行字符串,将其旋转90度后输出。
问题分析:
相关文章推荐
- uva 310 L--system(隐式图搜索+字符串处理)
- UVa 112|POJ 1145|Tree Summing|字符串处理|树的遍历
- uva140Bandwidth带宽——字符串处理加全排列
- UVa490 - Rotating Sentences-字符串-难度2
- Automatic Poetry - UVa 10361 简单字符串处理
- UVA - 123 Searching Quickly 字符串处理
- UVA 10082 WERTYU字符串处理
- UVA ~ 10815 ~ Andy's First Dictionary(set+字符串处理)
- UVA - 213 Message Decoding (输入字符串并对单个字符进行操作的输入输出)
- UVA 282 - Rename(字符串处理)
- Unix is 命令 (排序和字符串处理) UVA - 400
- UVA - 1339 Ancient Cipher :简单字符串处理
- UVA 10941 - Words adjustment(BFS+字符串处理)
- UVA 10905- Children's Game(sort处理string字符串)
- uva 310 L--system(隐式图搜索+字符串处理)
- UVA ~ 156 ~ Ananagrams(map+字符串处理)
- UVA - 1368 - DNA Consensus String (字符串处理)
- 03.shell字符串处理和输入输出
- uva 10361 Automatic Poetry(字符串处理)
- UVA 11988 Broken Keyboard (a.k.a. Beiju Text) 字符串处理