博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Symmetric Order
阅读量:5964 次
发布时间:2019-06-19

本文共 1934 字,大约阅读时间需要 6 分钟。

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

7BoPatJeanKevinClaudeWilliamMarybeth6JimBenZoeJoeyFrederickAnnabelle5JohnBillFranStanCece0

Sample Output

SET 1BoJeanClaudeMarybethWilliamKevinPatSET 2JimZoeFrederickAnnabelleJoeyBenSET 3JohnFranCeceStanBill
#include 
#include
using namespace std;string a[100],b[100];int main(){
int t=0,n,j,i,k;while(cin>>n,n!=0){
t++;j=1;k=0;for(i=1;i<=n;i++)cin>>a[i];for(i=1;i<=n;i++){
if(i%2!=0){
b[j]=a[i];j++;}else{
b[n-k]=a[i];k++;}}cout<<"SET "<
<
<=n;i++)cout<
<
 

转载于:https://www.cnblogs.com/lengxia/p/4387838.html

你可能感兴趣的文章
FastDFS存储服务器部署
查看>>
Android — 创建和修改 Fragment 的方法及相关注意事项
查看>>
swift基础之_swift调用OC/OC调用swift
查看>>
Devexpress 15.1.8 Breaking Changes
查看>>
Java B2B2C多用户商城 springcloud架构- common-service 项目构建过程(七)
查看>>
ElasticSearch Client详解
查看>>
新零售讲堂之时代下的传统零售业,何去何从?
查看>>
mybatis update返回值的意义
查看>>
expdp 详解及实例
查看>>
解读最具O2O属性—哈根达斯微信企业号的成功之道
查看>>
通过IP判断登录地址
查看>>
深入浅出JavaScript (五) 详解Document.write()方法
查看>>
Beta冲刺——day6
查看>>
在一个程序中调用另一个程序并且传输数据到选择屏幕执行这个程序
查看>>
Git - 操作指南
查看>>
正则表达式的贪婪与非贪婪模式
查看>>
SqlServer存储过程调用接口
查看>>
DOM
查看>>
NYOJ-取石子
查看>>
《zw版·Halcon-delphi系列原创教程》halconxlib控件列表
查看>>