首先声明,我是一个菜鸟。一下文章中出现技术误导情况盖不负责

Problem Description
As is known to all, long long ago sailormoon once was an association of fighters. Till now, sailormoon is also an association of girls. Owe to some unknown reasons, girls are necessary to fight for peace.
Their boss, lcy, wants to strengthen their ability, so he give them his precious collections---weapons for many years. Because these collections are really age-old, it is hard to recognize from one to another. So girls intend to sort them before they use. Each weapon has its name, origin and level of harmfulness ( level contains three ranks: wonderful, good, so-so).
In order to make it clear, girls want to sort like this:
firstly,sort according to the origin (sort by lexicographic order), if two or more have the same origin, they will be sorted together;
secondly, sort according ranks, wonderful is the best, good is next, the third is so-so;
thirdly, if two or more have same origin and rank, sort them according to the lexicographic order.

Input
Input contains multiply cases. Each case contains several lines. First line is an integer N(0<N<=500), representing the number of weapons. Then N lines follows. Each line represent a kind of weapon, and contains a set of strings representing name, origin and level of harmfulness.
Each string will not exceed 20 characters.
Sure that same origin will not exist the same weapon.
Output
Please output your list after sorting (format according to sample, pay attention to the spaces,ten spaces need ^ ^).
每日一道理
信念是巍巍大厦的栋梁,没有它,就只是一堆散乱的砖瓦;信念是滔滔大江的河床,没有它,就只有一片泛滥的波浪;信念是熊熊烈火的引星,没有它,就只有一把冰冷的柴把;信念是远洋巨轮的主机,没有它,就只剩下瘫痪的巨架。
Sample Input
5 knife qizhou so-so gun qizhou wonderful knife zhengzhou good stick zhengzhou good rope shengzhou so-so
Sample Output
Case 1 qizhou: gun wonderful knife so-so shengzhou: rope so-so zhengzhou: knife good stick good

一道简略的结构体排序

排序优先级

1:按持有者名字

2:按武器级别

3:按武器名字

水题

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;struct NODE
{char name[30];char lv[30];char ori[30];
} girl[505];int cmp(NODE x,NODE y)
{if(strcmp(x.ori,y.ori))return strcmp(x.ori,y.ori)<0;if(strcmp(x.lv,y.lv)){if(!strcmp(x.lv,"wonderful"))return 1;if(!strcmp(y.lv,"wonderful"))return 0;if(!strcmp(y.lv,"so-so"))return 1;if(!strcmp(x.lv,"so-so"))return 0;}return strcmp(x.name,y.name)<0;
}int main()
{int n,i,cas = 1;while(~scanf("%d",&n)){for(i = 0; i<n; i++)scanf("%s%s%s",girl[i].name,girl[i].ori,girl[i].lv);printf("Case %d\n",cas++);sort(girl,girl+n,cmp);char s[30];strcpy(s,girl[0].ori);int flag = 1;for(i = 0; i<n; i++){if(flag){printf("%s:\n",s);flag = 0;}printf("          %s %s\n",girl[i].name,girl[i].lv);if(strcmp(s,girl[i+1].ori)){strcpy(s,girl[i+1].ori);flag = 1;}}}return 0;
}

文章结束给大家分享下程序员的一些笑话语录: 自行车
一个程序员骑着一个很漂亮的自行车到了公司,另一个程序员看到了他,问 到,“你是从哪搞到的这么漂亮的车的?”
骑车的那个程序员说, “我刚从那边过来, 有一个漂亮的姑娘骑着这个车过来, 并停在我跟前,把衣服全脱了,然后对我说,‘你想要什么都可以’”。
另一个程序员马上说到, “你绝对做了一个正确的选择, 因为那姑娘的衣服你 并不一定穿得了”。

转载于:https://www.cnblogs.com/xinyuyuanm/archive/2013/05/22/3093604.html

武器排序HDU3293:sort相关推荐

  1. c#sort升序还是降序_Linux排序命令sort笔记

    很多时候Linux需要对文本相对比较规范的文本数据进行排序,这时候可以使用Linux系统下的sort命令进行处理. 语法格式:sort [-ntkr] filename 常用参数: -n 根据数字进行 ...

  2. pandas使用sort_values函数将dataframe按照指定数据列的内容对dataframe的数据行进行排序(sort dataframe rows by a specific column

    pandas使用sort_values函数将dataframe按照指定数据列的内容对dataframe的数据行进行排序(sort dataframe rows by a specific column ...

  3. pandas使用sort_index函数按照索引排序对dataframe的数据行进行排序(sort dataframe rows by index)

    pandas使用sort_index函数按照索引排序对dataframe的数据行进行排序(sort dataframe  rows by index) 目录 pandas使用sort_index函数按 ...

  4. seaborn使用boxplot函数可视化箱图并基于分组均值或者中位数进行箱图降序(descending)排序(Sort Boxplots in Descending Order)

    seaborn使用boxplot函数可视化箱图并基于分组均值或者中位数进行箱图降序(descending)排序(Sort Boxplots in Descending Order with Pytho ...

  5. R语言数据排序函数sort, order rank实战

    R语言数据排序函数sort, order & rank实战 目录 R语言数据排序函数sort, order & rank实战 #sort vs. order vs. rank函数基础 ...

  6. 经典排序算法 - 鸽巢排序Pigeonhole sort

    经典排序算法 - 鸽巢排序Pigeonhole sort 原理类似桶排序,同样需要一个很大的鸽巢[桶排序里管这个叫桶,名字无所谓了] 鸽巢其实就是数组啦,数组的索引位置就表示值,该索引位置的值表示出现 ...

  7. python 排序函数 sort sorted 简介

    sort() 是Python列表的一个内置的排序方法,list.sort() 方法排序时直接修改原列表,返回None: sort() 是Python内置的一个排序函数,它会从一个迭代器返回一个排好序的 ...

  8. 桶排序 Bin Sort

    桶排序 Bin Sort 平均情况下桶排序以线性时间运行.像计数排序一样,桶排序也对输入作了某种假设, 因而运行得很快.具体来说,计数排序假设输入是由一个小范围内的整数构成,而桶排序则 假设输入由一个 ...

  9. ajax id sort,ajax返回的json内容进行排序使用sort()方法实现

    ajax返回的json内容进行排序使用sort()方法实现 关键方法:sort()用于对数组的元素进行排序. return a.num-b.num是升序: return b.num-a.num;是降序 ...

最新文章

  1. iOS系统原生二维码条形码扫描
  2. 华为q1设置虚拟服务器,如何使用华为华为Q1 Q1互联网路由设置图文教程 | 192.168.1.1手机登陆...
  3. 解决数据库 Table 'content_tags' is marked as crashed and should be repaired 表损坏问题
  4. 关于db link权限分配的苦旅(一)
  5. Android抽屉(SlidingDrawer --类似android通知栏下拉效果)
  6. 华为二面!!!面试官直接问我Java中到底什么是NIO?这不是直接送分题???
  7. vm虚拟机安装_虚拟机 --- 安装VM(一)
  8. (转)Struts2的拦截器
  9. 《ggplot2:数据分析与图形艺术》,读书笔记
  10. 概率图模型之马尔可夫随机场
  11. Node.js 4493图片批量下载爬虫1.00
  12. matlab四节点矩形单元的应变,四节点矩形单元有限元分析
  13. 卅三先生的工程电磁场讲座.EEm05——边界条件001
  14. python format( )强力格式化
  15. python爬取酷狗音乐的mv地址_python爬取酷狗音乐排行榜
  16. 测试人员怎样定位bug原因
  17. Chrome——截图插件篇
  18. postgresql 页损坏(corrupted page)之checksum功能
  19. 电路设计经验总结(以软件cadence allegro为例)
  20. 区块链学习之Web3j入门(一)

热门文章

  1. Unity 笔刷大小过大甚至于调到最小都无法使用
  2. 关于字符设备文件和块设备文件的区别
  3. 一、C#语法与编程逻辑
  4. Java实现除去次方数
  5. 你是伪民主式父母吗?
  6. Number()String();
  7. Android 动画介绍及自定义3D动画效果的基本使用
  8. 弘辽科技:淘宝新链接怎么提升销量?需要注意什么?
  9. register_backward_hook(hook)、register_forward_hook(hook)、register_forward_pre_hook(hook)方法学习笔记
  10. Java 使用 POI 为 word 添加页眉 获取页眉