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. 安装 Google BBR 加速VPS网络

    Google BBR就是谷歌公司提出的一个开源TCP拥塞控制的算法.详情可以看这儿:https://lwn.net/Articles/701165.https://blog.sometimesnaiv ...

  2. http://www.onvif.org/onvif/ver20/util/operationIndex.html

    http://www.onvif.org/onvif/ver20/util/operationIndex.html

  3. option和 usb-serial驱动基本区别

    option.c This driver exists because the "normal" serial driver doesn't work too well   wit ...

  4. java版云笔记(三)

    登录与注册写好了下来就是主页,今天写的是主页加载时笔记本列表的显示,ajax是固定的就不重点说了.主要说一下jQuery.data() 函数和jQuery.on() 函数. 注:这个项目的sql文件, ...

  5. C# String.Format用法和格式说明

    1.格式化货币(跟系统的环境有关,中文系统默认格式化人民币,英文系统格式化美元) string.Format("{0:C}",0.2) 结果为:¥0.20 (英文操作系统结果:$0 ...

  6. 5.rabbitmq 主题

    1.生产者 #!/usr/bin/env python import pika import sys connection = pika.BlockingConnection(pika.Connect ...

  7. Java打包问题之一:打包出现java.io.IOException: invalid header field

    前言 java的打包工具jar有时候会出一些莫名其妙的问题,比如不合法的头部字段等等.这些问题之前也没注意,因为一直是用eclipse打包.后来在公司的时候,要求统一编写shell脚本来进行打包. 其 ...

  8. [Matlab]Upper Triangularization & Back Substitution代码

    用来做数值计算作业的代码,来自Numerical Methods Using Matlab (4th Edition) [John H. Mathews, Kurtis K. Fink],改了一下注释 ...

  9. spring_150908_hibernate_id_sequence

    1.新建java工程:spring_150908_hibernate_id_sequence,添加相关jar包(spring.hibernate.ibatis)如下图所示: 2.实现实体类DogPet ...

  10. Cordova - 禁用整个应用页面的上下拖动效果(防止拖动出现黑边)

    可在 config.xml 中进行如下设置:   <preference name="WebViewBounce" value="false" /> ...