寒假刷题之5——竹简文
来源:互联网 发布:淘宝88会员 8.8折 编辑:程序博客网 时间:2024/04/30 20:42
Rotating Sentences
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.
Input
Rene Decartes once said,"I think, therefore I am."
Output
"RIe nteh iDnekc,a rttheesreofnocree sIa iadm,."
感觉好水啊这题,题目很容易就看懂了,为了搞清楚输入输出细节我借助了google翻译,结果"I think, therefore I am."这句名言变成了刘若英说的,让人捧腹。。。
wa了几次,老会把空格打成a,定义ch数组时老是无法正常定义,遇到a条件输出空格也不行,不知道是错误出在哪里。。
#include<stdio.h>int main(){int i = 0, j = 0, maxj = 0, maxi;char ch[100][100], temp;int row[100] = {0};for (;(temp = getchar()) != EOF;){if (temp == '\n'){i ++;j = 0;}else if (temp != '\t'){ch[i][j++] = temp;if (maxj < j)maxj = j;row[i] = j;}}maxi = i - 1;for (j = 0; j < maxj; j ++){for (i = maxi; i >= 0; i --)printf("%c", j < row[i] ? ch[i][j]: ' ');printf("\n");}return 0;}
挺水的一题我做了也好久,看了我还是太弱了。。。
Rotating Sentences
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.
Input
Rene Decartes once said,"I think, therefore I am."
Output
"RIe nteh iDnekc,a rttheesreofnocree sIa iadm,."
感觉好水啊这题,题目很容易就看懂了,为了搞清楚输入输出细节我借助了google翻译,结果"I think, therefore I am."这句名言变成了刘若英说的,让人捧腹。。。
wa了几次,老会把空格打成a,定义ch数组时老是无法正常定义,遇到a条件输出空格也不行,不知道是错误出在哪里。。
#include<stdio.h>int main(){int i = 0, j = 0, maxj = 0, maxi;char ch[100][100], temp;int row[100] = {0};for (;(temp = getchar()) != EOF;){if (temp == '\n'){i ++;j = 0;}else if (temp != '\t'){ch[i][j++] = temp;if (maxj < j)maxj = j;row[i] = j;}}maxi = i - 1;for (j = 0; j < maxj; j ++){for (i = maxi; i >= 0; i --)printf("%c", j < row[i] ? ch[i][j]: ' ');printf("\n");}return 0;}
挺水的一题我做了也好久,看了我还是太弱了。。。
Rotating Sentences
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.
Input
Rene Decartes once said,"I think, therefore I am."
Output
"RIe nteh iDnekc,a rttheesreofnocree sIa iadm,."
wa了几次,老会把空格打成a,定义ch数组时老是无法正常定义,遇到a条件输出空格也不行,不知道是错误出在哪里。。
#include<stdio.h>int main(){int i = 0, j = 0, maxj = 0, maxi;char ch[100][100], temp;int row[100] = {0};for (;(temp = getchar()) != EOF;){if (temp == '\n'){i ++;j = 0;}else if (temp != '\t'){ch[i][j++] = temp;if (maxj < j)maxj = j;row[i] = j;}}maxi = i - 1;for (j = 0; j < maxj; j ++){for (i = maxi; i >= 0; i --)printf("%c", j < row[i] ? ch[i][j]: ' ');printf("\n");}return 0;}
- 寒假刷题之5——竹简文
- 银雀山汉墓竹简——孙子兵法
- 寒假刷题之2——Decoder
- 寒假刷题之3——小朋友来数数
- 寒假刷题之4——机械化表面?
- 寒假刷题之6——迷宫
- 寒假刷题之7——波纹
- 寒假刷题之8——侩子手游戏
- 寒假刷题之9——Collatz序列
- 寒假刷题之10——细菌密度
- 寒假刷题—栈和队列
- 寒假刷题之1——以生态为名义的剥削
- 2011贺岁片之——寒假计划
- 寒假实践之—大奖赛计分系统
- 寒假刷题——补模板——写新题
- 2016寒假训练——寒假结束
- 寒假后续刷题——回文与镜像文
- 寒假刷oj——黑豆传说
- ubuntu12.04安装JDK1.6
- Linux c中的位运算
- vb.net数据库编程(02):再来一个非查询的简单例子
- linux signal IPC进程间通信
- Java中的Enum的使用与分析
- 寒假刷题之5——竹简文
- 循环输出BMap.Marker标记
- CFileDialog用法
- 使用dom4j出现乱码解决方案
- win7防火墙设置开放某个端口
- Sencha Touch与PhoneGap,响应android返回按钮
- Android Activity之间切换出现短暂黑屏的处理方法
- mysql 新安装root 密码初始
- Logger与LogFactory