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界面截图,“排序”和“筛选”往往在一起,这大概是很多数据需要先排序后筛选吧 首先以“性别”作为排序字段,升序排列,并且第一行 ...
随机推荐
- PMBOK(第六版) PMP笔记-质量审计、风险审计、采购审计的区分
质量审计.风险审计.采购审计的区分 三个概念的相同之处: 都是审计的概念 都是特定知识领域的审计 三个概念的区别: (1)三个概念虽然都是审计,但分布在不同的管理过程组. ·质量审计:执行过程组, ...
- 程序猿的产品思考:2C与2B产品思维的区别
原创/朱季谦 我最早接触到互联网产品的时候,听到最多的,是做产品要有用户思维,即站在用户角度去看待产品.这个先入为主的概念,在很长一段时间里,都被我效作经典.然而也在很长一段时间里,我竟混淆了其中 ...
- [JOYOI1463] 智商问题
题目限制 时间限制 内存限制 评测方式 题目来源 1500ms 131072KiB 标准比较器 Local 题目背景 各种数据结构帝~ 各种小姊妹帝~ 各种一遍AC帝~ 来吧! 题目描述 某个同学又有 ...
- PowerShell攻击:nishang
nishanhg 下载地址:https://github.com/samratashok/nishing 1.简介 nishang的使用是要在PowerShell 3.0以上的环境中才可以正常使用 ...
- 百万年薪python之路 -- 内置函数练习
1.整理今天笔记,课上代码最少敲3遍. 2.用列表推导式做下列小题 过滤掉长度小于3的字符串列表,并将剩下的转换成大写字母 lst = [["a","b"],[ ...
- 【JS】深入理解JS原型和继承
前言 在学习JS中的原型,原型链,继承这些知识之前,我们先学习下基础知识:函数和对象的关系. 我们一直都知道,函数也是对象的一种,因为通过instanceof就可以判断出来.但是函数和对象的关系并不 ...
- Java基础(二十二)集合(4)Set集合
Set集合为集类型.集是最简单的一种集合,存放于集中的对象不按特定方式排序,只是简单地把对象加入集合中.对集中存放的对象的访问和操作时通过对象的引用进行的,所以,在集中不能存放重复对象. Set接口实 ...
- fenby C语言P21
数据类型 数组名字[个数]: #include <stdio.h> int main(){ int a[8]; float b[9]; char c[10]; return 0;}
- fenby C语言 P11
else {} if {} #include int main() { int a=15; if(a%2==0) { printf("我是偶数!"); }else { printf ...
- 【排列组合】给定一个M*N的格子或棋盘,从左下角走到右上角的走法总数(每次只能向右或向上移动一个方格边长的距离)
版权声明:本文为CSDN博主「梵解君」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明. 原文链接:https://blog.csdn.net/hadeso/art ...