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. 用C#实现对MSSqlServer数据库的增删改查---DAL层

    说明:本人完成的工作是对传感器--超声波物位计进行硬件集成,上位机通过串口接收传感器数据并将其存到数据库中:在DAL层实现对数据库的增删改查,其中包含两个数据表分别是WaterLevelSet表和Wa ...

  2. android 系统的休眠与唤醒+linux 系统休眠

    Android休眠与唤醒驱动流程分析 标准Linux休眠过程: powermanagement notifiers are executed with PM_SUSPEND_PREPARE tasks ...

  3. javascript 之数据类型--01

    写在前面 国庆整理资料时,发现刚开始入门前端时学习JS 的资料,打算以一个基础入门博客记录下来,有不写不对的多多指教: 先推荐些书籍给需要的童鞋 <JavaScript 高级程序设计.pdf&g ...

  4. 牛奶ddw如何通过以太坊钱包实现互相打赏

    很多朋友不清楚如何转账ddw,但是万能的网友是无敌的,这两天就自己摸索的一点经验总结下今天的转账经验. 1. 提取到自己的账户 这个大家都知道如何操作,使用官方的钱包 在“日日盈app”中点击&quo ...

  5. Python——文件打开模式辨析

    版权声明:本文系原创,转载请注明出处及链接. Python中,open()函数打开文件时打开模式如r.r+ .w+.w.a.a+有何不同 r 只能读 r+ 可读可写,不会创建不存在的文件.如果直接写文 ...

  6. 1、CentOS 6 安装GitLab

    1.安装和配置必需的依赖项 在CentOS上将系统防火墙打开HTTP和SSH访问. sudo yum install -y curl policycoreutils-python openssh-se ...

  7. linux 定时执行任务 at atq atrm命令的使用

    1.at命令在指定时刻执行指定的命令序列 at [-V] [-q 队列] [-f 文档名] [-mldbv] 时间 下面对命令中的参数进行说明.-V 将标准版本号打印到标准错误中.-q queue 使 ...

  8. Django之管理权限

    什么是权限: 谁对什么资源能做什么操作. 管理权限的实现有很多,这里实现一个最简单的管理权限的实现方式:rbac   ( role based access control ) 实现的一个基本思路: ...

  9. hdu 5912(迭代+gcd)

    Fraction Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

  10. Sublime Text 2之Emmet插件安装及使用

    1.安装Emmet How To Install?Reffer to this link:http://www.ituring.com.cn/article/47310 2.使用Emmet--Abbr ...