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. ROS学习记录(一)————创建简单的机器人模型smartcar

    这是我在古月居上找的(http://www.guyuehome.com/243),但直接运行的话,没办法跑起来,我也是查了好多博客和日志,才实现最后的功能的,所以,记录下来,以备后用吧,也欢迎其他和我 ...

  2. js函数防抖、节流实现

    防抖 Debounce 函数防抖就是,延迟一段时间再执行函数,如果这段时间内又触发了该函数,则延迟重新计算: // 简单实现 function debounce(fn, wait) { let t r ...

  3. 【1414软工助教】团队作业5——测试与发布(Alpha版本) 得分榜

    题目 团队作业5--测试与发布(Alpha版本) 作业提交情况情况 所有团队按时提交. 往期成绩 个人作业1:四则运算控制台 结对项目1:GUI 个人作业2:案例分析 结对项目2:单元测试 团队作业1 ...

  4. 第二次项目冲刺(Beta阶段)5.25

    1.提供当天站立式会议照片一张 会议内容: ①检查前一天的任务情况. ②制定新一轮的任务计划. ③对这几日的冲刺进行总结. 2.每个人的工作 (1)工作安排 队员 今日进展 明日安排 王婧 #63(完 ...

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

    1. 本周学习总结 1.1 尝试使用思维导图总结有关多态与接口的知识点. 1.2 可选:使用常规方法总结其他上课内容. 接口: 接口简而言之是方法声明和常量值的集合,接口中所有的方法默认为public ...

  6. 201521123114 《Java程序设计》第3周学习总结

    1. 本章学习总结 2. 书面作业 Q1.代码阅读 以上代码可否编译通过?哪里会出错?为什么?尝试改正? 如果创建3个Test1对象,有内存中有几个i,几个j?请分析原因? 不能编译通过,Test1g ...

  7. 201521123101 《Java程序设计》第1周学习总结

    1. 本周学习总结 在学习Java之前要做好准备工作,了解Java从研发后开始如何一步步完善,其与C++.C语言的异同,然后下载JDK.Eclipse.Notepad等软件,以便于未来的学习. 2. ...

  8. JavaScript的5中基本数据类型

    javascript的5种基本数据类型有: Undefined,Null,Bollean,Number,String,1种复杂数据类型:Object. 1Boolean类型 将一个值转换为Bollea ...

  9. 在dropwizard中使用feign,使用hystrix

    前言 用惯了spring全家桶之后,试试dropwizard的Hello World也别有一帆风味.为了增强对外访问API的能力,需要引入open feign.这里简单在dropwizard中使用fe ...

  10. codeforces 862B B. Mahmoud and Ehab and the bipartiteness

    http://codeforces.com/problemset/problem/862/B 题意: 给出一个有n个点的二分图和n-1条边,问现在最多可以添加多少条边使得这个图中不存在自环,重边,并且 ...