原题地址链接: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. SPI 用户空间的读写操作

    spi_device 虽然用户空间不需要直接用到spi_device结构体,但是这个结构体和用户空间的程序有密切的关系,理解它的成员有助于理解SPI设备节点的IOCTL命令,所以首先来介绍它.在内核中 ...

  2. Webpack学习错误解决笔记

    错误1:在用npm install 安装模块时,时常会出现没有以下类似的错误 解决方法:右键点击node_modules文件夹,选取属性,将文件夹只读选项去除 错误2:在学习到清理/dist文件夹这块 ...

  3. 索引(Awakening!)

    orz写个索引,方便日后复习和补充. 目前笔记还不是很多,而且写得比较烂,望各位到访的巨佬谅解. 大概可以算作一个归纳总结? ……没链接的还没开始写或者没写完,而且不知道什么时候才能写完(咕咕咕) 一 ...

  4. Mac休眠之后唤醒时无法使用鼠标

    Mac休眠之后唤醒时,无法使用鼠标键盘,无法输入密码登录,只能重启. 尝试升级系统,问题依旧,最后在Google的帮助下,问题解决. 解决办法:系统偏好设置->节能->取消硬盘休眠 参考: ...

  5. 用Docker构建分布式Redis集群

    [编者的话]本文介绍了如何使用Docker搭建Redis集群,很多读者都在问Docker能带来哪些实质性的好处,我想本文就是一个很好的例子.不使用Docker你也可以搭建Redis集群,那使用Dock ...

  6. Node.js环境搭建&&npm安装

    Node.js环境搭建 什么使Node.js呢?我们知道JavaScript开始作为客户端语言,但早已在浏览器端一统江湖,这时,野心越来越大,它就想向服务器端拓展了,于是Node.js就是这样的,我们 ...

  7. 2 小时学会 Spring Boot

    一. 什么是 Spring Boot Takes an opinionated view of building production-ready Spring applications. Sprin ...

  8. 在eclipse中启动Tomcat报端口被占用的错误

    安装配置好Tomcat之后,在浏览器中输入localhost,能正取打开页面.然后在eclipse中建立项目,创建Servlet之后,启动Tomcat,报端口被占用的错误.如图: 原因:原来已经启动了 ...

  9. 虹软linux错误

  10. Integer 与 int -- 自动装箱(autoboxing)与自动拆箱(unboxing)

    转载于 http://www.ticmy.com/?p=110 jdk1.5引入了自动装箱(autoboxing)与自动拆箱(unboxing),这方便了集合类以及一些方法的调用,同时也使初学者对其感 ...