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. WebServices 之 WSDL

    详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt234 一,WSDL概述 WebServices Description La ...

  2. NSMutable属性声明时为什么不能使用copy

    在iOS开发里面我们经常会进行NSMutable(可变类型的类,常用的如NSMutableString,NSMutableArray,NSMutableDictionary,NSMutableData ...

  3. PowerBI入门 第三篇:报表设计技巧

    最近做了几个PowerBI报表,对PowerBI的设计有了更深的理解,对数据的塑形(sharp data),不仅可以在Data Source中实现,例如在TSQL查询脚本中,而且可以在PowerBI中 ...

  4. 移动端图片放大滑动查看-插件photoswipe的使用

    最近在开发项目的时候,遇到一个需求,需要移动端实现放大查看图片的功能,然后我就在网上搜索了一下资料,看到了photoswipe这个插件,后来试了试,确实挺好用的,它可以实现手势放大缩小查看图片,左右滑 ...

  5. C语言之算法初步(汉诺塔--递归算法)

    个人觉得汉诺塔这个递归算法比电子老鼠的难了一些,不过一旦理解了也还是可以的,其实网上也有很多代码,可以直接参考.记得大一开始时就做过汉诺塔的习题,但是那时代码写得很长很长,也是不理解递归的结果.现在想 ...

  6. 201521123010 《Java程序设计》第14周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结多数据库相关内容. 2. 书面作业 1. MySQL数据库基本操作 建立数据库,将自己的姓名.学号作为一条记录插入.(截图,需出现自 ...

  7. 201521123053《Java程序设计》第十三周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 书面作业 TCP和UDP两者之间的区别: UDP:1)将数据及源和目的封装成数据包中,不需要建立连接 ...

  8. Zookeeper-5分钟快速掌握分布式应用程序协调服

    一.Zookeeper 安装 1.zookeeper支持brew安装. ➜ ~ brew info zookeeper zookeeper: stable (bottled), HEAD Centra ...

  9. RAID磁盘阵列

    什么是RAID 独立硬盘冗余阵列(RAID, Redundant Array of Independent Disks),简称磁盘阵列.其基本思想就是把多个相对便宜的硬盘组合起来,成为一个硬盘阵列组, ...

  10. java面试之Hashmap

    在java面试中hashMap应该说一个必考的题目,而且HashMap 和 HashSet 是 Java Collection Framework 的两个重要成员,其中 HashMap 是 Map 接 ...