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: ...
随机推荐
- iOS动画详解(二)
UIImage常用的绘图操作 一个UIImage对象提供了向当前上下文绘制自身的方法.我们现在已经知道如何获取一个图片类型的上下文并将它转变成当前上下文. 平移操作:下面的代码展示了如何将UI ...
- eclipse jetty启动内存溢出
一.eclipse jetty启动内存溢出, 异常信息 Exception in thread "ConfigClientWorker-Default" java.lang.Out ...
- 最牛X的编码套路
最近,我大量阅读了Steve Yegge的文章.其中有一篇叫"Practicing Programming"(练习编程),写成于2005年,读后令我惊讶不已: 与你所相信的恰恰相反 ...
- hdu3589 Jacobi symbol(二次剩余 数论题)
本题的注意点:n=p1*p2*p3......Pm 解法:直接利用公式a^((p-1)/2)=(a/p)mod p 即可求解. #include<stdio.h> #include< ...
- 在与SQL Server建立连接时出现与网络相关的或特定于实例的错误
向往前一样.学习牛腩新闻公布系统的视频,写程序,打开数据库.出现一个框框,具体内容例如以下: 数据库连接不上.全部的工作都要歇班,捣鼓了会儿,简单总结一下解决该问题的方法. 首先:第一步,程序--SQ ...
- iOS开发——面试指导
iOS面试指导 一 经过本人最近的面试和对面试资料的一些汇总,准备记录这些面试题,以便ios开发工程师找工作复习之用,本人希望有面试经验的同学能和我同时完成这个模块,先出面试题,然后会放出答案. 1. ...
- [006]为什么C++会被叫做是C++?
先了解一下自增和自减的运算符: 自增(++)和自减(--)操作符为对象提供加1或减1操作: int i = 0, j; j = ++i; // j = 1, i = 1: prefix yields ...
- linux vi 撤销重做于前进后退--转
在vi中按u可以撤销一次操作 u 撤销上一步的操作Ctrl+r 恢复上一步被撤销的操作 注意:如果你输入“u”两次,你的文本恢复原样,那应该是你的Vim被配置在Vi兼容模式了.重做如果你撤销得太多 ...
- Android进阶笔记04:Android进程间通讯(IPC)之Messenger
一. Android进程间通讯之Messenger 的引入 (1)引言: 平时一说进程间通讯,大家都会想到AIDL,其实messenger和AIDL作用一样,都可以进行进程间通讯.它是基于消 ...
- jsp HTTP Status 405 - HTTP method GET is not supported by this URL
package myservlet.control; import java.io.IOException; import java.io.PrintWriter; import javax.serv ...