OpenJudge/Poj 2013 Symmetric Order
1.链接地址:
http://bailian.openjudge.cn/practice/2013
http://poj.org/problem?id=2013
2.题目:
Symmetric Order
Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 11793 Accepted: 7181 Description
In your job at Albatross Circus Management (yes, it's run by a bunch of clowns), you have just finished writing a program whose output is a list of names in nondescending order by length (so that each name is at least as long as the one preceding it). However, your boss does not like the way the output looks, and instead wants the output to appear more symmetric, with the shorter strings at the top and bottom and the longer strings in the middle. His rule is that each pair of names belongs on opposite ends of the list, and the first name in the pair is always in the top part of the list. In the first example set below, Bo and Pat are the first pair, Jean and Kevin the second pair, etc.Input
The input consists of one or more sets of strings, followed by a final line containing only the value 0. Each set starts with a line containing an integer, n, which is the number of strings in the set, followed by n strings, one per line, sorted in nondescending order by length. None of the strings contain spaces. There is at least one and no more than 15 strings per set. Each string is at most 25 characters long.Output
For each input set print "SET n" on a line, where n starts at 1, followed by the output set as shown in the sample output.Sample Input
7
Bo
Pat
Jean
Kevin
Claude
William
Marybeth
6
Jim
Ben
Zoe
Joey
Frederick
Annabelle
5
John
Bill
Fran
Stan
Cece
0Sample Output
SET 1
Bo
Jean
Claude
Marybeth
William
Kevin
Pat
SET 2
Jim
Zoe
Frederick
Annabelle
Joey
Ben
SET 3
John
Fran
Cece
Stan
BillSource
3.思路:
4.代码:
#include<iostream>
#include<cstdio>
#include <cstring>
using namespace std;
char a[][];
int main()
{
int i,count=,n;
while(scanf("%d",&n)!=EOF&&n)
{
memset(a, , sizeof(a));
for(i=;i<n;i++) cin>>a[i];
printf("SET %d\n",count);
count++;
for(i=;i<n;i+=) cout<<a[i]<<endl;
for(i=n--(n%);i>=;i-=) cout<<a[i]<<endl;
}
//system("pause");
return ;
}
OpenJudge/Poj 2013 Symmetric Order的更多相关文章
- poj 2013 Symmetric Order 解题报告
题目链接:http://poj.org/problem?id=2013 设长度非递减的字串序列为s[1]...s[n].设计递归子程序print(n),其中n为字串序号,每分析1个字串,n=n-1. ...
- OpenJudge/Poj 1844 Sum
1.链接地址: http://bailian.openjudge.cn/practice/1844 http://poj.org/problem?id=1844 2.题目: Sum Time Limi ...
- OpenJudge/Poj 1723 SOLDIERS
1.链接地址: http://bailian.openjudge.cn/practice/1723/ http://poj.org/problem?id=1723 2.题目: 总时间限制: 1000m ...
- OpenJudge/Poj 1316 Self Numbers
1.链接地址: http://poj.org/problem?id=1316 http://bailian.openjudge.cn/practice/1316 2.题目: 总时间限制: 1000ms ...
- OpenJudge/Poj 1159 Palindrome
1.链接地址: http://bailian.openjudge.cn/practice/1159/ http://poj.org/problem?id=1159 2.题目: Palindrome T ...
- OpenJudge/Poj 1207 The 3n + 1 problem
1.链接地址: http://bailian.openjudge.cn/practice/1207/ http://poj.org/problem?id=1207 2.题目: 总时间限制: 1000m ...
- OpenJudge / Poj 2141 Message Decowding
1.链接地址: http://poj.org/problem?id=2141 http://bailian.openjudge.cn/practice/2141/ 2.题目: Message Deco ...
- OpenJudge/Poj 2105 IP Address
1.链接地址: http://poj.org/problem?id=2105 http://bailian.openjudge.cn/practice/2105 2.题目: IP Address Ti ...
- OpenJudge/Poj 2027 No Brainer
1.链接地址: http://bailian.openjudge.cn/practice/2027 http://poj.org/problem?id=2027 2.题目: 总Time Limit: ...
随机推荐
- readonly disabled 区别
readonly 提交表单时包含该属性的内容 控件 disabled 不包含该属性
- [Java 7][msvcr100.dll] Error when load Eclipse
[Problem] After I updated to Java 7, I could not load Eclipse. Here comes the erros: Eclipse: eclips ...
- 教你50招提升ASP.NET性能(四):精选的技巧
(4)A selection of tips 招数4: 精选的技巧 Make sure HTTP compression is turned on for any uncompressed conte ...
- Config the Android 5.0 Build Environment
In this document Choosing a Branch Setting up a Linux build environment Installing the JDK ...
- IIS 之 查看并发连接数
如果要查看IIS连接数,最简单方便的方法是通过“网站统计”来查看,“网站统计”的当前在线人数可以认为是当前IIS连接数.然而,“网站统计”的当前在线人数统计时间较长,一般为10分钟或15分钟,再加上统 ...
- Google前工程经理王忻:如何准备软件工程师的面试
http://t.jobdu.com/thread-368-1-1.html 导读:原文作者王忻,Google前工程经理,2003年月加入Google,是Google Lively背后的主导力量,是G ...
- Google实习面试归来
咱们寝室共有两个人收到面试通知,我和另一哥们G. 今天早上8:30起了个大早,洗漱完毕,简历复印完毕,就和G骑车到达了世贸中 心酒店那儿.真不愧是世贸中心啊,装修就是华丽,连看门的都是印 ...
- ListView中不同类型view的实现
首先创建请求队列,一个活动中只需要一个,因此放在Application中: public class MyApplication extends Application{ private static ...
- jquery easyui combobox 级联及触发事件,combobox级联
jquery easyui combobox 级联及触发事件,combobox级联 >>>>>>>>>>>>>>&g ...
- Centos 6.4 安装elasticsearch+kibana
elasticsearch和kibanna的链接地址:https://www.elastic.co/downloads,我的环境里用的包为kibana-4.1.1-linux-x64.tar.gz和e ...