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.

Sample Input

  1. Rene Decartes once said,
  2. "I think, therefore I am."

Sample Output

  1. "R
  2. Ie
  3. n
  4. te
  5. h
  6. iD
  7. ne
  8. kc
  9. ,a
  10. r
  11. tt
  12. he
  13. es
  14. r
  15. eo
  16. fn
  17. oc
  18. re
  19. e
  20. s
  21. Ia
  22. i
  23. ad
  24. m,
  25. .
  26. "
    ----------------------------------------------------------------------------------------
    ac代码:
  1. #include<stdio.h>
  2. #define MAXN 100+10
  3. char array[MAXN][MAXN];
  4. int rowArray[MAXN] = {};
  5. int maxCol = ;
  6. int main(){
  7.  
  8. char c;
  9. int row = ,column = ;
  10.  
  11. int i,j;
  12.  
  13. while((c = getchar())!= EOF){
  14. if(c == '\n'){//遇到换行,行数加1,列数清0
  15. row++;
  16. column = ;
  17. }else{
  18. array[row][column++] = c;
  19. ++rowArray[row];
  20. if(rowArray[row] > maxCol){
  21. maxCol = rowArray[row];
  22. }
  23. }
  24. }
  25.  
  26. for(i = ; i < maxCol; i++){
  27. for(j = row-; j >= ; j--){
  28. c = (i < rowArray[j]) ? array[j][i]:' ';
  29. printf("%c",c);
  30. }
  31. printf("\n");
  32. }
  33.  
  34. return ;
  35. }

其中需要注意的是:

27行,j = row -1,若是j=row的话输出会多出一列空格。

490 - Rotating Sentences的更多相关文章

  1. UVa 490 - Rotating Sentences

    https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=94&page=s ...

  2. Rotating Sentences

    #include<bits/stdc++.h> #define N 110 int main(void) { char s[N][N]; int i, j, k, max; , memse ...

  3. UVA_490:Rotating Sentences

    "R  Ie   n  te  h  iD  ne  kc  ,a   r  tt  he  es  r  eo  fn  oc  re  e   s  Ia   i  ad  m,  .  ...

  4. UVA题目分类

    题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics ...

  5. 【索引】Volume 0. Getting Started

    AOAPC I: Beginning Algorithm Contests (Rujia Liu) Volume 0. Getting Started 10055 - Hashmat the Brav ...

  6. RQNOJ 490 环形石子合并

    题目链接:https://www.rqnoj.cn/problem/490 题目描述 在一个园形操场的四周摆放N堆石子,现要将石子有次序地合并成一堆.规定每次只能选相邻的2堆合并成新的一堆,并将新的一 ...

  7. 【英语魔法俱乐部——读书笔记】 3 高级句型-简化从句&倒装句(Reduced Clauses、Inverted Sentences) 【完结】

    [英语魔法俱乐部——读书笔记] 3 高级句型-简化从句&倒装句(Reduced Clauses.Inverted Sentences):(3.1)从属从句简化的通则.(3.2)形容词从句简化. ...

  8. 【英语魔法俱乐部——读书笔记】 2 中级句型-复句&合句(Complex Sentences、Compound Sentences)

    [英语魔法俱乐部——读书笔记] 2 中级句型-复句&合句(Complex Sentences.Compound Sentences):(2.1)名词从句.(2.2)副词从句.(2.3)关系从句 ...

  9. 【英语魔法俱乐部——读书笔记】 1 初级句型-简单句(Simple Sentences)

    第一部分 1 初级句型-简单句(Simple Sentences):(1.1)基本句型&补语.(1.2)名词短语&冠词.(1.3)动词时态.(1.4)不定式短语.(1.5)动名词.(1 ...

随机推荐

  1. java之进程和线程

    1.进程和线程的通俗例子. 2.进程和线程关系.

  2. 如何有规律的备份 WordPress 博客(转)

    转自:http://blog.wpjam.com/m/backup-your-blog-regularly/   我们都知道备份 WordPress 博客应该是规律性的操作,但是事实上往往我们都会因为 ...

  3. React 函数传参

    import React, { Component } from 'react'; import { render } from 'react-dom'; class GroceryList exte ...

  4. HDU4112

    对于n*m*k的方块,用手掰成1**1的那么搜需要的步骤是固定的,为n*m*k-,如果用刀切,因为可以把多块叠在一起切,所以对于长度为n的,将他切成0,所需要的步骤数位k 对于n*m*k的方块,用手掰 ...

  5. bzoj1601 / P1550 [USACO08OCT]打井Watering Hole(堆优化prim)

    P1550 [USACO08OCT]打井Watering Hole   对于自己建水库的情况,新建一个虚拟结点,和其他点的边权即为自建水库的费用 这样问题就转化为一个裸最小生成树问题了. 这里用堆优化 ...

  6. 20145326 《Java程序设计》第10周学习总结

    教材学习内容总结 网络编程 •网络编程就是在两个或两个以上的设备(例如计算机)之间传输数据. •程序员所作的事情就是把数据发送到指定的位置,或者接收到指定的数据,这个就是狭义的网络编程范畴. •在发送 ...

  7. POJ 2699 The Maximum Number of Strong Kings (最大流+枚举)

    http://poj.org/problem?id=2699 题意: 一场联赛可以表示成一个完全图,点表示参赛选手,任意两点u, v之间有且仅有一条有向边(u, v)或( v, u),表示u打败v或v ...

  8. UVa 10054 项链(欧拉回路)

    https://vjudge.net/problem/UVA-10054 题意:有一种由彩色珠子连接成的项链.每个珠子的两半由不同颜色组成.相邻两个珠子在接触的地方颜色相同.现在有一些零碎的珠子,需要 ...

  9. 组学航母----OMICtools

    OMICtools可谓是组学研究的航空母舰,其收集了基因组学.转录组学.蛋白质组学和代谢组学等分析研究常用的4400余个工具和数据库.它允许用户submit自己的工具/数据库,每一个上传的工具/数据库 ...

  10. SpringBoot在启动时的多环境配置以及加载顺序

    通常我们在开发完成一个SpringBoot项目时,总是要打包部署的. 在启动SpringBoot应用时,我们常常会使用命令java -jar xxx.jar来启动这个服务. 命令java -jar 除 ...