原题地址链接: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. 遇见Navicat 2003-can't connect to MYSQL server on 'localhost'(10061)

    学习过程中难免遇到问题,今天就遇到了Navicat 2003-can't connect to MYSQL server on 'localhost'(10061),navicat报错,我就纳闷以前都 ...

  2. bingoyes' tiny dream

    Gauss Elimination bool Gauss(){ int now=1,nxt; double t; R(i,1,n){ //enumerate the column for(nxt=no ...

  3. xilinx DMA IP核(二) —— 文档阅读

    本笔记不记录DMA的Scatter/Gather特性.DMA上有三种总线:AXI4-LIte(对寄存器进行配置),AXI4-Memory Map(用于与内存交互)和AXI4 Stream(用于与外设交 ...

  4. Sublime Text 3安装插件(Mac 10.12)

    1.先安装Package Control,默认这个是没有安装的. 使用[control + -]打开控制台,输入以下代码: import urllib.request,os; pf = 'Packag ...

  5. Struts2方法调用的三种方式(有新的!调用方法的说明)

    在Struts2中方法调用概括起来主要有三种形式 第一种方式:指定method属性 <action name="heroAction" class="com.ABC ...

  6. rocksDB vs InnoDB vsTokuDB

    原文地址 https://minervadb.com/index.php/2018/08/06/comparing-tokudb-rocksdb-and-innodb-performance-on-i ...

  7. Scala IDEA for Eclipse里用maven来创建scala和java项目代码环境(图文详解)

    这篇博客 是在Scala IDEA for Eclipse里手动创建scala代码编写环境. Scala IDE for Eclipse的下载.安装和WordCount的初步使用(本地模式和集群模式) ...

  8. 初始设置ubuntu 16.04 Vps部署rails

    参考 https://blog.longwin.com.tw/2005/12/ssh_keygen_no_passwd/ 1 选择搬瓦工左边菜单栏中的“Root password modificati ...

  9. 十分有趣的this指向题

    var num=5;//9 =>++this.num=>10 var obj={ num:3, fn:function() { num = 9;//window.num=9 (functi ...

  10. 关于对Enum的理解

    之前一直对枚举类型的理解存在误解,现重新学习 Enum 类型的介绍 枚举类型(Enumerated Type) 很早就出现在编程语言中,它被用来将一组类似的值包含到一种类型当中.而这种枚举类型的名称则 ...