原题地址链接: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 =
≤ L ≤ Large dataset N =
≤ L ≤

Sample:

Input 

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

Perl算法:

#!/usr/bin/perl
my $infile='B-large-practice.in';
my $outfile='B-large-out.out';
open my $in,'<',$infile
or die "Cannot open $infile:$!\n";
open my $out,'>',$outfile
or die "Cannot open $outfile:$!\n"; chomp(my $N=<$in>);
my $line;
my @res;
for(my $i=;$i<=$N;$i++){
chomp($line=<$in>);
@res=split " ",$line; #将一行的字符串分隔开来,以便于利用 reverse 函数进行翻转
@res=reverse @res;
print $out "Case #$i: @res\n"; }
close $in;
close $out;

上传原题地址链接网站,结果正确

Google APAC----Africa 2010, Qualification Round(Problem B. Reverse Words)----Perl 解法的更多相关文章

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

    Google Code Jam Africa 2010 Qualification Round Problem B. Reverse Words https://code.google.com/cod ...

  2. 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 ...

  3. 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 ...

  4. 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 ...

  5. Google Code Jam 2009 Qualification Round Problem C. Welcome to Code Jam

    本题的 Large dataset 本人尚未解决. https://code.google.com/codejam/contest/90101/dashboard#s=p2 Problem So yo ...

  6. Google Code Jam 2009 Qualification Round Problem B. Watersheds

    https://code.google.com/codejam/contest/90101/dashboard#s=p1 Problem Geologists sometimes divide an ...

  7. Google Code Jam 2009 Qualification Round Problem A. Alien Language

    https://code.google.com/codejam/contest/90101/dashboard#s=p0 Problem After years of study, scientist ...

  8. [C++]Infinite House of Pancakes——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

  9. [C++]Standing Ovation——Google Code Jam 2015 Qualification Round

    Problem It’s opening night at the opera, and your friend is the prima donna (the lead female singer) ...

随机推荐

  1. C#生成验证码类

    using System;using System.Collections.Generic;using System.Drawing;using System.Drawing.Drawing2D;us ...

  2. Gradle学习系列(三)

    上一篇我们已经学习了 Gradle 打包,那么这一节 就开始讲讲本章的第二版块:打包及使用Gradle过程中的常见错误问题. 有时候我们需要编辑一个开源项目之类的,希望把它导入了我们自己的IDE工具中 ...

  3. Linux下ls命令使用详解(转)

    说明:我们在linux下使用ll时,其实就是ls -l.ls才是最终的命令程序. ls命令是linux下最常用的命令之一,ls跟dos下的dir命令是一样的都是用来列出目录下的文件,List即列表的意 ...

  4. Yii 使用Widge面面观

    我们可以把Widget视为一个嵌入到控制器管理 的视图中的微控制器,其实就是.net框架中的用户控件,或者类似于.net MVC中的子视图.与controller相比较,微件没有既没有动作,也没有过滤 ...

  5. 【LESS系列】高级特性

    前面我已经有一篇文章是写 LESS 的基础语法的. 那么这一次我们来看一下 LESS 的高级特性. 说起高级特性,首先也必须要一提的是模式匹配. 虽然个人觉得模式匹配的实用度其实也是一般般,但在关键时 ...

  6. JavaScript -- 定义二维数组

    方法一:直接定义并且初始化,这种遇到数量少的情况可以用var _TheArray = [["0-1","0-2"],["1-1"," ...

  7. FPGA加速:面向数据中心和云服务的探索和实践

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文由columneditor 发表于云+社区专栏 作者介绍:章恒--腾讯云FPGA专家,目前在腾讯架构平台部负责FPGA云的研发工作,探索 ...

  8. 【c++】字符串流输出恢复状态问题

    缘起 #include <iostream> #include <sstream> using namespace std; int main() { istringstrea ...

  9. Android6.0内核移植(1):分析编译日志

    在下面命令之后产生的编译日志进行分析 source build/envsetup.sh lunch sabresd_6dq-user make -j20 ======================= ...

  10. 获取服务器时间ajax

    $.ajax({ type:"OPTIONS", url:"/", complete:function(x){ // alert(x.getResponseHe ...