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. Android学习记录:线程

    在Java中,线程的建立方法如下. 新建一个类,接口Runnable,重载 run方法 import javax.swing.JTextField; public class test impleme ...

  2. 使用JSR-303进行校验 @Valid

    一.在SringMVC中使用 使用注解 1.准备校验时使用的JAR validation-api-1.0.0.GA.jar:JDK的接口: hibernate-validator-4.2.0.Fina ...

  3. MongoDB学习之路(四)

    MongoDB插入文档 MongoDB使用insert()或save()方法向集合中插入文档. db.COLLECTION_NAME.insert(document); For instance &g ...

  4. JavaScript 的使用基础总结①

    JavaScript 使用   JavaScript 是一种轻量级的编程语言,JavaScript 是可插入 HTML 页面的编程代码,JavaScript 插入 HTML 页面后,可由所有的现代浏览 ...

  5. 团队作业4——第一次项目冲刺(Alpha版本)第六天and第七天

    团队作业4--第一次项目冲刺(Alpha版本)第六天and第七天 第一次项目冲刺(Alpha版本)第六天 一.Daily Scrum Meeting照片   二.燃尽图 1.解释说明横纵坐标代表的含义 ...

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

    1.本周学习总结 2. 书面作业 代码阅读 public class Test1 { private int i = 1;//这行不能修改 private static int j = 2; publ ...

  7. java程序设计-算术表达式的运算

    1.团队课程设计博客链接 洪亚文博客链接:http://www.cnblogs.com/201521123065hyw/ 郑晓丽博客链接:http://www.cnblogs.com/zxl3066/ ...

  8. 安装wampserve之前需要安装vc++2012.

    本人是64位系统下载了wampserver3.0.6之后安装好,启动报错缺少msvcr110.dll. 于是从网上下载了msvcr110.dll放到了windows的syswow64文件夹下,甚至还重 ...

  9. 二分求最长上升子序列 二分LIS

    #include <iostream> #include <cstring> #define N 50010 using namespace std; int n; int n ...

  10. JSP知识点大纲图

    这是我整理出来的JSP知识点大纲图,具体的内容都可以在我的博文中找到-.