AOAPC I: Beginning Algorithm Contests (Rujia Liu) ::Volume 0. Getting Started
Description
给你一堆字符串,你可以看作图像。
将这个图像顺时针旋转90度输出。
Type
Water
Analysis
读取字符串,存在一个二维数组中。
然后对这个二维数组,按一定规则输出即可。
注意各个字符串的长度不同,
因此某个位置字符为空时,可能需要输出空格。
Solution
// UVaOJ 490
// Rotating Sentences
// by A Code Rabbit
#include <cstdio>
#include <cstring>
char str[102][102];
int tot_str;
int main() {
int max = 0;
for (tot_str = 0; gets(str[tot_str]); tot_str++)
if (strlen(str[tot_str]) > max)
max = strlen(str[tot_str]);
tot_str--;
for (int i = 0; i < max; i++) {
for (int j = tot_str; j >= 0; j--)
printf("%c", str[j][i] ? str[j][i] : ' ');
printf("\n");
}
return 0;
}