UVa 490 Rotating sentences
来源:互联网 发布:男士双肩包推荐知乎 编辑:程序博客网 时间:2024/06/05 12:50
【解题思路】
这道题目的样例输出格式着实一坑,需要注意输出时要在根据字符串的最大长度进行空格补位。
以下是另补的样例输入输出,用字符‘*’代表空格,空行即为换行。
输入样例1
ab
cde
输出样例1
ca
db
e*
输入样例2
1a
3b
*c
5
输出样例2
5**3*1
**cb*a
由样例可见,输出实际上就是将输入的各种不等长的字符串通过空格补位,使之变成矩形,再将其顺时针旋转90度输出即可。
【代码】
#include<stdio.h>#include<string.h>int main(){int row, maxlen;char str[102][102];int len[102];row = 0;maxlen = 0;while (gets(str[row]) != NULL) { //这里的输入包含空格,故整行输入len[row] = strlen(str[row]);if (maxlen < len[row]) {maxlen = len[row];}row ++;}for (int j = 0; j < maxlen; j ++) { //从列开始,90度旋转输出for (int i = row-1; i >= 0; i --) {if (j < len[i])printf("%c", str[i][j]);elseprintf(" ");//输出补上空格}printf("\n");}return 0;}
0 0
- Uva 490 Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA-490-Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa:490 - Rotating Sentences
- UVA 490 Rotating Sentences
- UVA:490 - Rotating Sentences
- UVA - 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa 490 - Rotating Sentences
- UVa 490 Rotating sentences
- UVA - 490 Rotating Sentences
- UVA 490 Rotating Sentences
- UVA - 490 Rotating Sentences
- UVa 490 - Rotating Sentences
- UVA 490 Rotating Sentences
- 13.3 集成测试
- 黑马程序员_JAVA基础 用户输入1024,则输出“一万零二十四”
- 字符串的所有全排列
- Chrome 中的 JavaScript 断点设置和调试技巧
- 读书笔记(一) 疯狂JAVA讲义 第三章 数据类型和运算符
- UVa 490 Rotating sentences
- 黑马程序员_JAVA基础-运算符
- iOS7开发学习之路:No.8 引导页(2) 使用PageViewController
- Python扫描指定目录下(包括子目录)的文件
- POJ 2263 Heavy Cargo(Floyd变形)
- Rotate a UIImage by 90 degree angles
- C 输入一串数字,去掉其中含7的和能被7整除的数
- JSP简单练习-数组应用实例
- 设置Eclipse配色方案--设置不同背景色,有效护眼