nyoj 283-对称排序 (sort)
283-对称排序
内存限制:64MB
时间限制:1000ms
特判: No
通过数:2
提交数:4
难度:1
题目描述:
输入描述:
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, NOT SORTED. 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.
输出描述:
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.
If length of two strings is equal,arrange them as the original order.(HINT: StableSort recommanded)
样例输入:
7
Bo
Pat
Jean
Kevin
Claude
William
Marybeth
6
Jim
Ben
Zoe
Joey
Frederick
Annabelle
5
John
Bill
Fran
Stan
Cece
0
样例输出:
SET 1
Bo
Jean
Claude
Marybeth
William
Kevin
Pat
SET 2
Jim
Zoe
Frederick
Annabelle
Joey
Ben
SET 3
John
Fran
Cece
Stan
Bill
C/C++ AC:
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <queue>
#include <climits>
#define PI 3.1415926 using namespace std;
const int MY_MAX = ;
int N; bool cmp(string a, string b)
{
return a.size() < b.size();
} int main()
{
int t = ;
while (scanf("%d", &N), N)
{
string my_str[];
int flag[] = {};
for (int i = ; i < N; ++ i)
{
cin >>my_str[i];
}
sort(my_str, my_str + N, cmp); // 题目的意思,先根据长度排序 printf("SET %d\n", t ++);
for (int i = ; i < N; i += )
{
cout <<my_str[i] <<endl;
flag[i] = ;
}
for (int i = N - ; i > ; -- i)
{
if (!flag[i])
cout <<my_str[i] <<endl;
}
}
}
nyoj 283-对称排序 (sort)的更多相关文章
- Lucene 排序 Sort与SortField
在sql语句中,有升序和降序排列.在Lucene中,同样也有. Sort里的属性 SortField里的属性 含义 Sort.INDEXORDER SortField.FIELD_DOC 按照索引的顺 ...
- 转:详细解说 STL 排序(Sort)
详细解说 STL 排序(Sort) 详细解说 STL 排序(Sort) 作者Winter 详细解说 STL 排序(Sort) 0 前言: STL,为什么你必须掌握 1 STL提供的Sort 算法 1. ...
- NYOJ一种排序
//最重要的收获就是懂得了,还可以调用库函数直接对结构体进行排序sort(const void *,const void *,cmp) /* bool cmp(rect c,rect d) { if( ...
- 设计模式 - 模板方法模式(template method pattern) 排序(sort) 具体解释
模板方法模式(template method pattern) 排序(sort) 具体解释 本文地址: http://blog.csdn.net/caroline_wendy 參考模板方法模式(tem ...
- [js] - 关于js的排序sort
js的排序sort并不能一次排序好 function solution(nums){ return nums.sort(sortNumber); } function sortNumber(a, b) ...
- 给乱序的链表排序 · Sort List, 链表重排reorder list LoLn...
链表排序 · Sort List [抄题]: [思维问题]: [一句话思路]: [输入量]:空: 正常情况:特大:特小:程序里处理到的特殊情况:异常情况(不合法不合理的输入): [画图]: quick ...
- 详细解说 STL 排序(Sort)(转)
作者Winter 详细解说 STL 排序(Sort) 0 前言: STL,为什么你必须掌握 1 STL提供的Sort 算法 1.1 所有sort算法介绍 1.2 sort 中的比较函数 1.3 sor ...
- nyoj_283_对称排序_201312051155
对称排序 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 In your job at Albatross Circus Management (y ...
- Excel VBA解读(54):排序——Sort方法
Excel VBA解读(54):排序——Sort方法 看看下面的Excel界面截图,“排序”和“筛选”往往在一起,这大概是很多数据需要先排序后筛选吧 首先以“性别”作为排序字段,升序排列,并且第一行 ...
随机推荐
- [NOIp2011] luogu P1311 选择客栈
我妈的抽象歌曲真 nb. 题目描述 给你 nnn 个点,每个点有两个参数 ci,dic_i,d_ici,di,给你一个数 DDD.定义一种方案合法,当且仅当你选出整数 i,j∈[1,n],i< ...
- C#版ASP.NET Web API使用示例
为更好更快速的上手Webapi设计模式的接口开发,本文详细解释了在Web API接口的开发过程中,我们可能会碰到各种各样的问题总结了这篇,希望对大家有所帮助. 1:在接口定义中确定MVC的get或者P ...
- Dubbo+Zookeeper(一)Zookeeper初识
前面花了一段时间去学习SpringCloud的相关知识,主要是理解微服务的概念并使用SpringCloud的一系列组件实现微服务落地.学习这些组件本身是简单的,跟着操作一遍基本就会了,这也得益于Spr ...
- 安装并使用SourceTree进行代码管理(Mac环境)
应用场景 对于我们开发人员来说,熟练使用Git是最基本的技能之一.SourceTree又是一款比较好的Git UI工具,是 Windows 和Mac OS X 下免费的 Git 和 Hg 客户端,主要 ...
- 七、springBoot 简单优雅是实现文件上传和下载
前言 好久没有更新spring Boot 这个项目了.最近看了一下docker 的知识,后期打算将spring boot 和docker 结合起来.刚好最近有一个上传文件的工作呢,刚好就想起这个脚手架 ...
- git jenkins 基本部署之git远程仓库
1.git远程仓库如何使用? 实战一.如何将本地仓库与远程Gitee进行关联? 1.注册gitee 2.创建一个远程仓库? 3.配置使用远程仓库 ...
- HashMap - 类注释
了解到Java8以后HashMap的实现换了,也看了很多博客一直在向我这个小菜鸡说HashMap的重要.因此我决定洗心革面,好好正视HashMap 基于jdk 8 先从类注释开始入手学习,顺便提高提高 ...
- CPU爆满后的无助感
告警 晚七点刚好上地铁,握在手里的手机震动了好几下,根据震动这几下的手感已经判断出这是钉钉在告警了,十有八九就是线上的问题,通过Zabbix监控的一台线上服务器已经五分钟不可达,这应该不会是网络网络问 ...
- JVM概述和类加载器
JVM概述 1.Java虚拟机所管理的内存包括以下几个运行时数据区域: ①.程序计数器 程序计数器是一块较小的内存空间,可以看做是当前线程所执行的字节码的行号指示器,字节码解释器工作时就是 ...
- Unity系统消息广播
# 1.前言Unity自带消息系统,如SendMessage等,此方法利用的反射,且会反射游戏物体上的所有组件,对性能不友好.而且由于参数为方法名称,所以如果使用代码混淆,则会无法调用 方法,且难以追 ...