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

 1 #include<stdio.h>
2 #include<iostream>
3 #include<algorithm>
4 #include<string>
5 using namespace std;
6
7 int main()
8 {
9 int t;
10 cin >> t;
11 getchar();
12 while(t--)
13 {
14 int cas;
15 cin >> cas;
16 getchar();
17 while(cas--)
18 {
19 string s, t;
20 getline(cin, s);
21 t.clear();
22 int flag = 0;
23 for(int i = 0; i < s.length(); i++)
24 {
25 if(s[i] != ' ' && i <= s.length() - 1)
26 t += s[i];
27 else
28 {
29 reverse(t.begin(), t.end());
30 if(flag)
31 cout << " ";
32 cout << t;
33 flag = 1;
34 t.clear();
35 }
36 }
37 reverse(t.begin(), t.end());
38 cout << " " << t << endl;
39 }
40 return 0;
41 }
42
43 }

Word Reversal(string)的更多相关文章

  1. zoj1151 zoj1295 Word Reversal 字符串的简单处理

    Word Reversal Time Limit: 2 Seconds      Memory Limit:65536 KB For each list of words, output a line ...

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

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

  3. Word Reversal

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

  4. ZOJ 1151 Word Reversal

    原题链接 题目大意:给一句话,把每个单词倒序,然后输出. 解法:我是用了一个堆栈,以空格来拆分单词,把每个字母压入堆栈,然后依次输出. 参考代码: /* * 字符串反向,140ms,188kb * 单 ...

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

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

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

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

  7. 139. Word Break (String; DP)

    Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separa ...

  8. 萌新笔记——C++里将string类字符串(utf-8编码)分解成单个字(可中英混输)

    最近在建词典,使用Trie字典树,需要把字符串分解成单个字.由于传入的字符串中可能包含中文或者英文,它们的字节数并不相同.一开始天真地认为中文就是两个字节,于是很happy地直接判断当前位置的字符的A ...

  9. Leetcode: Word Squares && Summary: Another Important Implementation of Trie(Retrieve all the words with a given Prefix)

    Given a set of words (without duplicates), find all word squares you can build from them. A sequence ...

随机推荐

  1. Go的map

    目录 map 一.map的创建 1.map的类型 2.定义并初始化 二.给map添加元素 三.获取map的元素 四.删除map的元素 五.获取map的长度 六.map的类型 七.map的相等性 八.循 ...

  2. How DRI and DRM Work

    How DRI and DRM Work Introduction This page is intended as an introduction to what DRI and DRM are, ...

  3. 清除浏览器默认样式的reset.css(转载于reset.css的官方)

    /* http://meyerweb.com/eric/tools/css/reset/ v2.0-modified | 20110126 License: none (public domain) ...

  4. 剑指 Offer 49. 丑数 + 小根堆 + 动态规划

    剑指 Offer 49. 丑数 Offer_49 题目详情 解法一:小根堆+哈希表/HashSet 根据丑数的定义,如果a是丑数,那么a2, a3以及a*5都是丑数 可以使用小根堆存储按照从小到大排序 ...

  5. 操作系统---在内核中重新加载GDT和堆栈

    摘要 用BIOS方式启动计算机后,BIOS先读取引导扇区,引导扇区再从外部存储设备中读取加载器,加载器读取内核.进入内核后,把加载器中建立的GDT复制到内核中. 这篇文章的最大价值也许在末尾,对C语言 ...

  6. CVE-2017-12149-JBoss 5.x/6.x 反序列化

    漏洞分析 https://www.freebuf.com/vuls/165060.html 漏洞原理 该漏洞位于JBoss的HttpInvoker组件中的 ReadOnlyAccessFilter 过 ...

  7. linux 设置系统时间

    第一种: 服务器date时间不准: root@mdy-zabbix2:~# date Fri Sep 28 09:58:56 UTC 2018 实际是下午6点 第一步:执行tzselect 第二步: ...

  8. Codeforces Round #685 (Div. 2)

    待补 A #include <bits/stdc++.h> using namespace std; int n; int main() { int __; scanf("%d& ...

  9. Codeforces Round #557 B. Double Matrix

    题面: 传送门 题目描述: 给出两个n*m的矩阵,问:是否能通过交换两个矩阵"对应"位置的元素,使两个矩阵都为"递增"矩阵. "递增"矩阵定 ...

  10. 自导自演的面试现场之--你竟然不了解MySQL的组提交?

    Hi,大家好!我是白日梦!本文是MySQL专题的第 26 篇. 下文还是白日梦以自导自演的方式,围绕"组提交"展开本话题.看看你能抗到第几问吧 换一种写作风格,自导自演面试现场!感 ...