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: ...
随机推荐
- Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列
C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- BZOJ 2298: [HAOI2011]problem a 动态规划
2298: [HAOI2011]problem a Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://www.lydsy.com/JudgeOnli ...
- 一个GCC4.6.3的奇妙问题的糊涂解决方案
因为工作中需要OpenCV,又不想用Windows,所以我就在Linux下编译安装OpenCV了.一开始,由于我的计算机不能安装ubuntu12.04,所以我安装了ubuntu13.04,opencv ...
- springMVC3学习(五)--MultiActionController
Spring提供一个多动作控制器,使用它你能够将几个动作合并在一个控制器里,这样能够把功能组合在一起. 多动作控制器存在在一个单独的包中--org.springframework.web.mvc.mu ...
- Hive权限介绍
一.开启权限 眼下hive支持简单的权限管理,默认情况下是不开启.这样全部的用户都具有同样的权限.同一时候也是超级管理员.也就对hive中的全部表都有查看和修改的权利,这样是不符合一般数据仓库的安全原 ...
- Java下拼接运行动态SQL语句
mod=viewthread&tid=3039" target="_blank">Java拼接动态SQL的一般做法有 1.使用动态语句 非常多数 ...
- [React Fundamentals] State Basics
State is used for properties on a component that will change, versus static properties that are pass ...
- [React Native] Reusable components with required propType
In this React Native lesson, we will be creating a reusable Badge component. The component will also ...
- 在Struts2中使用ValueStack、ActionContext、ServletContext、request、session等 .
笔者不知道该用哪个词来形容ValueStack.ActionContext等可以在Struts2中用来存放数据的类.这些类使用的范围不同,得到的方法也不同,下面就来一一介绍. 声明:本文参考Strut ...
- C#_MVC_分页update
private static string getLinkHtml(UrlHelper urlHelper, bool useAjax, string ajaxSuccessFunction, str ...