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 or 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.
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, . "
#define RUN #ifdef RUN #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <string> #include <iostream> #include <sstream> #include <map> #include <set> #include <vector> #include <list> #include <cctype> #include <algorithm> #include <utility> #include <math.h> using namespace std; #define MAXN 105 char buf[MAXN][MAXN]; char c; int rows = 0; // Total rows of input int len = 0; // Length of each row int maxlen = 0; void printout(){ for(int i=0; i<rows; i++){ for(int j=0; j<strlen(buf[i]); j++){ printf("%c", buf[i][j]); } printf("\n"); } } void rotate(){ for(int i=0; i<maxlen; i++){ for(int j=rows-1; j>=0; j--){ printf("%c", buf[j][i]); } printf("\n"); } } int main(){ #ifndef ONLINE_JUDGE freopen("490.in", "r", stdin); freopen("490.out", "w", stdout); #endif memset(buf, ' ', sizeof(buf)); while(scanf("%c", &c)!=EOF){ if(c == '\n'){ if(len > maxlen){ maxlen = len; } len = 0; rows++; continue; } buf[rows][len++] = c; } //printout(); rotate(); } #endif
相关推荐
Design-and-Electromagnetic-Feature-Analysis-of-AC-Rotating-Machines 作者Ahmed Masmoudi 适合电机人员学习
iOS游戏应用源代码——funkyboy-How-To-Create-a-Rotating-Wheel-Control.zip
day03-Rotating nav animation(旋转导航动画)
安装npm install react-native-rotating-text --save用法import RotatingText from 'react-native-rotating-text'特性款式(个数) (默认: {}) 您要应用于文本的任何样式对象。 项目(数组) (默认值:['第一',...
自动切换模式Tab选项卡 - Rotating jQuery tabs
Silverlight 2.0 - Rotating 3D Image Cube - Box_Src_Example。
安装pip install scrapy-rotating-proxies用法将带有代理列表的ROTATING_PROXY_LIST选项添加到settings.py: ROTATING_PROXY_LIST = [ 'proxy1.com:8000', 'proxy2.com:8031', # ...]或者,您可以指定一个ROTATING_...
android工程,图片UI特效-镜面旋转,特炫
An approach for simulating the microwave heating process with a slow- rotating sample and a fast-rotating mode stirrer
这是一个简单的java图片旋转例子 这个例子不错主要功能都很好
Nonsequential double ionization (NSDI) of noble gas atoms in counter-rotating two-color circularly polarized (CRTC) laser fields is investigated. A scaling law is concluded by qualitatively and ...
图片的查看 上一张下一张 使用c# vs2013编辑
使用react-rotating-text的最简单方法是从NPM安装它,并将其包含在您自己的React构建过程中(使用 , , 等)。 您还可以通过在页面中包含dist/react-rotating-text.js来使用独立构建。 如果使用它,请确保已经包含...
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
官方离线安装包,亲测可用。使用rpm -ivh [rpm完整包名] 进行安装
离线安装包,亲测可用
@ vrbo / pino-rotating-file介绍一种传输,用于过滤日志条目并将其写入自动旋转的文件中。 未过滤的日志条目将从stdout中继续输出。 当您想在不同的旋转文件中使用不同的条目时,这对于日志记录很有用。 使用旋转...
API RP 687-2023 - Special-purpose Rotating Equipment Repairs.pdf
新版完整标准 IEC 60034-33-2022 Rotating electrical machines - Part 33_ Synchronous hydrogenerators including motor-generators - Specific requ.pdf
A tunable ultrafast intensity-rotating optical field is generated by overlapping a pair of 20 Hz, 800 nm chirped pulses with a Michelson interferometer (MI). Its rotating rate can be up to 10 trillion...