Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words

https://code.google.com/codejam/contest/351101/dashboard#s=p1

Problem

Given a list of space separated words, reverse the order of the words. Each line of text contains L letters and W words. A line will only consist of letters and space characters. There will be exactly one space character between each pair of consecutive words.

Input

The first line of input gives the number of cases, N.
N test cases follow. For each test case there will a line of letters and space characters indicating a list of space separated words. Spaces will not appear at the start or end of a line.

Output

For each test case, output one line containing "Case #x: " followed by the list of words in reverse order.

Limits

Small dataset

N = 5
1 ≤ L ≤ 25

Large dataset

N = 100
1 ≤ L ≤ 1000

Sample

Input  Output 
3
this is a test
foobar
all your base
Case #1: test a is this
Case #2: foobar
Case #3: base your all

Solution:

vector<string> solve1(vector<string>words)
{
reverse(words.begin(), words.end());
return words;
} int main() {
freopen("in", "r", stdin);
//freopen("out", "w", stdout); int t_case_num;
scanf("%d\n", &t_case_num);
if (!t_case_num) {
cerr << "Check input!" << endl;
exit();
} // Read input set
for (int case_n = ; case_n <= t_case_num; case_n++) { string line;
getline(cin, line);
stringstream ss(line); vector<string>words; string w;
while (ss >> w) {
words.push_back(w);
} auto result = solve1(words);
printf("Case #%d: ", case_n);
for (int i = ; i < result.size(); i++) {
cout << result.at(i) << " ";
}
printf("\n"); } fclose(stdin);
fclose(stdout);
return ;
}

Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words的更多相关文章

  1. Google Code Jam Africa 2010 Qualification Round Problem A. Store Credit

    Google Code Jam Qualification Round Africa 2010 Problem A. Store Credit https://code.google.com/code ...

  2. Google APAC----Africa 2010, Qualification Round(Problem B. Reverse Words)----Perl 解法

    原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p1 问题描述: Problem Given a list of s ...

  3. Google APAC----Africa 2010, Qualification Round(Problem C. T9 Spelling)----Perl 解法

    原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p2 问题描述: Problem The Latin alphabe ...

  4. Google APAC----Africa 2010, Qualification Round(Problem A. Store Credit)----Perl 解法

    原题地址链接:https://code.google.com/codejam/contest/351101/dashboard#s=p0 问题描述: Problem You receive a cre ...

  5. Google Code Jam 第一题

    通过的第一题,留做纪念,呵呵,非常简单,Africa 2010, Qualification Round: Store Credit. #include <stdio.h> #includ ...

  6. [C++]Store Credit——Google Code Jam Qualification Round Africa 2010

    Google Code Jam Qualification Round Africa 2010 的第一题,很简单. Problem You receive a credit C at a local ...

  7. Google Code Jam 2010 Round 1C Problem A. Rope Intranet

    Google Code Jam 2010 Round 1C Problem A. Rope Intranet https://code.google.com/codejam/contest/61910 ...

  8. [Google Code Jam (Qualification Round 2014) ] B. Cookie Clicker Alpha

    Problem B. Cookie Clicker Alpha   Introduction Cookie Clicker is a Javascript game by Orteil, where ...

  9. [Google Code Jam (Qualification Round 2014) ] A. Magic Trick

    Problem A. Magic Trick Small input6 points You have solved this input set.   Note: To advance to the ...

随机推荐

  1. PHP深浅拷贝

    举个栗子: <?php class Example1 { public $name; public function __construct($name) { $this->name = ...

  2. docker安装总结 linux红帽系列

    由于Docker限制分为两个版本CE和EE,所以之前yum里面的docker是老版本,需要先进行卸载,现在的包名叫做docker-ce yum remove docker docker-common ...

  3. Django【设计】同功能不同实现模式的兼容性

    需求: 当我们采集硬件信息时,客户端可以有多种方式,具体方式取决于客户机,CMDB项目中,我们有三种方式可选,AGENT/SSH/SALT,根据客户机具体情况和“SALT>>SSH> ...

  4. Android上HDMI介绍(基于高通平台)

    本文重点针对HDMI在android上的应用,而比较相关的就是overlay机制.overlay在这里只是简单的介绍,后续会有文章再专门详述. 我没记错的话,高通从7X30开始,平台就可以支持HDMI ...

  5. eWebEditor复制粘贴图片时过滤域名

    1.找到form.js 路径:plugins/frame/scripts/form.js 这个方法: 2.替换这个方法 /** * 处理参数 */ Form.prototype.processReqP ...

  6. [转载]锁无关的数据结构与Hazard指针——操纵有限的资源

    Lock-Free Data Structures with Hazard Pointers 锁无关的数据结构与Hazard指针----操纵有限的资源 By Andrei Alexandrescu a ...

  7. 集合框架之Set学习

    前言:         1.何为框架:可以理解为一个基础结构,在基础结构上进行进一步开发会变得很方便. 2.三种集合类型:集合(Set) :元素无序不可重复: 列表(List) :元素有序可重复: 映 ...

  8. UBuntu14.04 --vim安装YouCompleteMe插件

    说明 我电脑的系统参数(用 uname -a命令查看)如下: Linux avyn-Lenovo --generic #-Ubuntu SMP Tue Mar :: UTC i686 i686 i68 ...

  9. 20165301 2017-2018-2 《Java程序设计》第二周学习总结

    20165301 2017-2018-2 <Java程序设计>第二周学习总结 教材学习内容总结 第二章:基本数据类型与数组 标识符 第一个字符不能是数字 不能是关键字 不能是true.fa ...

  10. 三、ansible简要使用

    1.ansible服务器生成公钥与私钥 ssh-keygen -t rsa 2.拷贝ansible公钥到客户机上 ssh-copy-id -i root@192.168.1.1 3.添加主机到ansi ...