Word Reversal


Time Limit: 2 Seconds      Memory Limit:65536 KB

For each list of words, output a line with each word reversed without changing the order of the words.

This problem contains multiple test cases!

The first line of a multiple input is an integer N, then a blank line followed by N input blocks. Each input block is in the format indicated in the problem description. There is a blank line between input blocks.

The output format consists of N output blocks. There is a blank line between output blocks.

Input

You will be given a number of test cases. The first line contains a positive integer indicating the number of cases to follow. Each case is given on a line containing a list of words separated by one space, and each word contains
only uppercase and lowercase letters.

Output

For each test case, print the output on one line.

Sample Input

1

3
I am happy today
To be or not to be
I want to win the practice contest

Sample Output

I ma yppah yadot
oT eb ro ton ot eb
I tnaw ot niw eht ecitcarp tsetnoc

http://blog.csdn.net/AC_0_summer/article/details/44747401

#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
using namespace std;
char s[];
void _S()
{
int L=;
s[L++]=getchar();
while(s[L-]!='\n'){
if(s[L-]==' ')
{
for(int i=L-;i>=;i--)
putchar(s[i]);
printf(" ");
L=;
}
s[L++]=getchar();
}
for(int i=L-;i>=;i--)
putchar(s[i]);
printf("\n");
return ;
} int main()
{
int n,T; scanf("%d",&T);
while(T--){
scanf("%d\n",&n);//过滤换行符
while(n--) _S();
if(T) printf("\n"); //此题容易因为此处PE
}
return ;
}
zoj1295:
#include<cstdio>
#include<cstdlib>
#include<iostream>
using namespace std;
void _S()
{
char s[];
int num=;
char c=getchar();
while(true){
if(c=='\n'){
for(int i=num;i>=;i--) cout<<s[i];
cout<<endl;
return ;
}
s[++num]=c;
c=getchar();
}
}
int main()
{
int n;
scanf("%d\n",&n);
while(n--)
_S()
return ;
}


为什么感觉题目没有解释很清楚,让那么多人PE。。。。。。。。。。。

当然本题处理方式有很多,也可以每一行输入后再处理。个人属于习惯单个字符输入的那种(此时要注意过滤换行符什么的)。

zoj1151 zoj1295 Word Reversal 字符串的简单处理的更多相关文章

  1. zoj 1151 Word Reversal(字符串操作模拟)

    题目连接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1151 题目描述: For each list of words ...

  2. 【Android进阶】Gson解析json字符串的简单应用

    在客户端与服务器之间进行数据传输,一般采用两种数据格式,一种是xml,一种是json.这两种数据交换形式各有千秋,比如使用json数据格式,数据量会比较小,传输速度快,放便解析,而采用xml数据格式, ...

  3. java生成RSA公私钥字符串,简单易懂

    java生成RSA公私钥字符串,简单易懂   解决方法: 1.下载bcprov-jdk16-140.jar包,参考:http://www.yayihouse.com/yayishuwu/chapter ...

  4. MiniWord .NET Word模板引擎,藉由Word模板和数据简单、快速生成文件。

    Github / Gitee QQ群(1群) : 813100564 / QQ群(2群) : 579033769 介绍 MiniWord .NET Word模板引擎,藉由Word模板和数据简单.快速生 ...

  5. Word Reversal (简单字符串处理)

    题目描述: For each list of words, output a line with each word reversed without changing the order of th ...

  6. ZOJ 1151 Word Reversal反转单词 (string字符串处理)

    链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=151 For each list of words, output a l ...

  7. 对上次“对字符串进行简单的字符数字统计 探索java中的List功能 ”程序,面向对象的改进

    之前的随笔中的程序在思考后发现,运用了太多的static 函数,没有将面向对象的思想融入,于是做出了一下修改: import java.util.ArrayList; import java.util ...

  8. 对字符串进行简单的字符数字统计 探索java中的List功能

    题目: 统计一个字符串中数字和字符串的个数,并分别进行排列,要求 1.数字,字符串可以从键盘获取. 2.储存在list 3.统计数字个数,字符串个数 4.把数字和字符串按从小到大的顺序输出 5.不能使 ...

  9. Word Reversal

    For each list of words, output a line with each word reversed without changing   the order of the wo ...

随机推荐

  1. Python Keras module 'keras.backend' has no attribute 'image_data_format'

    问题: 当使用Keras运行示例程序mnist_cnn时,出现如下错误: 'keras.backend' has no attribute 'image_data_format' 程序路径https: ...

  2. 我的天哪,现在的移动VIN码识别已经这么。。

    VIN码是英文(Vehicle Identification Number)的缩写,译为车辆识别代码,又称车辆识别码,车辆识别代码,车辆识别号,车辆识别代号,VIN码是表明车辆身份的代码.VIN码由1 ...

  3. POJ 1236 tarjan

    Network of Schools Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19613   Accepted: 77 ...

  4. JS中的事件&对象

    一.JS中的事件 (一)JS中的事件分类 1.鼠标事件 click/dblclick/onmouseover/onmouseout 2.HTML事件 onload/onscroll/onsubmit/ ...

  5. 201521123082《Java程序设计》第4周学习总结

    201521123082<Java程序设计>第4周总结 标签(空格分隔): java 1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内 ...

  6. Beta冲刺前准备

    一.介绍小组新成员,Ta担任的角色. 201421123121 栗海辉 来自Sugar Free 风格:低调中的高调,给你不一样的视觉 擅长的技术:C语言/JAVA 在曾经的团队里面担任主要编程人员, ...

  7. 201521123011 《java程序设计》 第7周学习总结

    1. 本周学习总结 参考资料: XMind 2. 书面作业 1.ArrayList代码分析 1.1 解释ArrayList的contains源代码 1.2 解释E remove(int index)源 ...

  8. 201521123005 《Java程序设计》 第九周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结异常相关内容. 2. 书面作业 本次PTA作业题集异常 1.常用异常 题目5-1 1.1 截图你的提交结果(出现学号) 1.2 自己 ...

  9. 生成/etc/shadow文件中的密码

    shadow文件的格式就不说了.就说说它的第二列--密码列. 通常,passwd直接为用户指定密码就ok了.但在某些情况下,要为待创建的用户事先指定密码,还要求是加密后的密码,例如kickstart文 ...

  10. 关于在jsp页面中使用/struts-tags标签库的迭代器时,从ValueStack获取参数使用EL的问题

    情况复原下: 通过valuestack存了个user,然后页面里可以${user.sex}拿到男.${user.sex=='男'}拿到ture 但是在使用 <s:if text="${ ...