UVA - 490 Rotating Sentences
2016-04-23 09:50
417 查看
Rotating Sentences
Submit Status
Description
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.
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.
分析:
格式输出。水
代码:
#include<stdio.h>
#include<string.h>
int main()
{
char st[102][102],ch;
int maxlen = 0,top = 0,lenth[102];
while((gets(st[top])) != NULL)
{
if(strlen(st[top]) > maxlen)
maxlen = strlen(st[top]);
lenth[top] = strlen(st[top]);
top++;
}
int i,j,k;
for(i = 0;i < maxlen; i++)
{
for(j = top-1;j >= 0; --j)
{
if(lenth[j] > i)
printf("%c",st[j][i]);
else//其实所谓的细节就是在某一行的没有字符的位置,输出空格
printf(" ");
}
printf("\n");
}
return 0;
}
Time Limit: 3000MS | Memory Limit: Unknown | 64bit IO Format: %lld & %llu |
Description
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 orupper 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, . "
分析:
格式输出。水
代码:
#include<stdio.h>
#include<string.h>
int main()
{
char st[102][102],ch;
int maxlen = 0,top = 0,lenth[102];
while((gets(st[top])) != NULL)
{
if(strlen(st[top]) > maxlen)
maxlen = strlen(st[top]);
lenth[top] = strlen(st[top]);
top++;
}
int i,j,k;
for(i = 0;i < maxlen; i++)
{
for(j = top-1;j >= 0; --j)
{
if(lenth[j] > i)
printf("%c",st[j][i]);
else//其实所谓的细节就是在某一行的没有字符的位置,输出空格
printf(" ");
}
printf("\n");
}
return 0;
}
相关文章推荐
- java的debug和release编译方式
- 个人理解的 Https 通信流程
- [BZOJ1911][Apio2010]特别行动队(斜率优化dp)
- 使用supervisord管理进程
- Eclipse 安卓开发导入SlidingMenu侧滑菜单这些坑!!
- 第九周项目 员工薪水类
- hihocoder1181 欧拉路
- 伪分布式hadoop搭建步骤
- Bnuoj 4315 美女来找茬
- 面经一
- bzoj 1012: [JSOI2008]最大数maxnumber(线段树)
- jQuery选择器
- easyUI组件datagrid的二次封装
- jQuery 获取多选框的值
- 二次排序说明
- 数据结构复习总结
- 第九周项目 2.1 我的数组类
- mvc、mvvm、mvp模式区分
- poj 1182 食物链
- Android Volley完全解析(一),初识Volley的基本用法