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

Language:C++ 4.8.2

#include<stdio.h>
#include<string.h>
#define MAXN 100+10
char str[MAXN][MAXN];
int main(void)
{
memset(str, 0, sizeof(str));
int count = 0;
while(fgets(str[count], MAXN, stdin) != NULL)
count++;
// 程序执行到这里,count代表读入句子的个数
int max_length = 0;
for(int i = 0; i < count; i++)
{
int length = strlen(str[i]);
if(max_length < length)
max_length = length;
} max_length--; // 没有这一行的话,程序WA,这是由fgets的特性决定的,因为在我们开的空间足够大的情况下,字符串会以'\n'和'\0'结尾。
int row, col;
for(row = 0; row < max_length; row++)
{
for(col = 0; col < count; col++)
{
int ch = str[count-1-col][row];
if(ch == '\0' || ch == '\n')
putchar(' ');
else
putchar(ch);
} putchar('\n'); // 注意:如果该行前加语句if(row != max_length -1),也会WA,个中缘由自己体会吧。
}
return 0;
} PS:开始理解错题意了,以为每行的输入字符个数是递增的,导致一直A不了。

UVA_490:Rotating Sentences的更多相关文章

  1. 490 - Rotating Sentences

     Rotating Sentences  In ``Rotating Sentences,'' you are asked to rotate a series of input sentences ...

  2. UVa 490 - Rotating Sentences

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

  3. Rotating Sentences

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

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

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

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

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

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

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

  9. hdu 3307 Description has only two Sentences (欧拉函数+快速幂)

    Description has only two SentencesTime Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K ...

随机推荐

  1. osg如何设置抗锯齿(反走样,反锯齿)

    首先抗锯齿是什么? 举个最简单的例子 你用windows画图软件画一根直线(准确说这个叫做线段),当水平或者垂直的时候,如下图,这是绝对完美的 但是当线段出现倾斜时,就无法做到完美了此时就会出现锯齿 ...

  2. Blow up the city

    Blow up the city 时间限制: 1 Sec  内存限制: 128 MB 题目描述 Country A and B are at war. Country A needs to organ ...

  3. Luogu P3953 逛公园(最短路+记忆化搜索)

    P3953 逛公园 题面 题目描述 策策同学特别喜欢逛公园.公园可以看成一张 \(N\) 个点 \(M\) 条边构成的有向图,且没有自环和重边.其中 \(1\) 号点是公园的入口,\(N\) 号点是公 ...

  4. Luogu P3254 圆桌问题(最大流)

    P3254 圆桌问题 题面 题目描述 假设有来自 \(m\) 个不同单位的代表参加一次国际会议.每个单位的代表数分别为 \(r_i (i =1,2,--,m)\) . 会议餐厅共有 \(n\) 张餐桌 ...

  5. Java IO : NIO与IO的区别

    参考资料:https://dzone.com/articles/java-nio-vs-io NIO是面向流的,IO是面向缓冲流的. NIO是非线程阻塞的,IO是线程阻塞的. NIO的Selector ...

  6. import schedule ImportError: No module named schedule

    安装pip sudo apt-get install python-pip 安装schedule模块 pip install schedule PS: 如果已经安装pip,可能出现以下问题,按照提示重 ...

  7. php时间戳转换方式

    {echo date("Y-m-d",$v.created)} 年-月-日 {echo date("Y-m-d H:i:s",$new.created)} 年- ...

  8. windows 和 mac 文件夹共享问题汇总

    目标:windows上的文件夹,共享给MAC,mac可以将文件复制到windows上来 windows设置共享文件夹,然后在mac上访问 假设win的ip地址是10.10.27.11,则mac上远程方 ...

  9. R语言中如何使用最小二乘法

    R语言中如何使用最小二乘法 这里只是介绍下R语言中如何使用最小二乘法解决一次函数的线性回归问题.         代码如下: > x<-c(6.19,2.51,7.29,7.01,5.7, ...

  10. Spring的IoC容器(转)BeanFactory

    Spring的IoC容器 Spring读书笔记-----Spring的Bean之Bean的基本概念 加菲猫 Just have a little faith. Spring的IoC容器 (用户持久化类 ...