九度教程--------2
来源:互联网 发布:建筑行业网站知乎 编辑:程序博客网 时间:2024/04/29 14:04
九度教程第二题
源代码
#include <stdio.h>#include <algorithm>#include <string.h> using namespace std;struct E {char name[101];int age;int score; bool operator < (const E &b) const{if(score != b.score) return score < b.score;int tmp = strcmp(name,b.name);if(tmp != 0) return tmp < 0;else return age < b.age; } }buf[1000];/*bool cmp(E a,E b){if(a.score != b.score) return a.score < b.score;int tmp = strcmp(a.name,b.name);if(tmp != 0) return tmp < 0;else return a.age < b.age; } */int main(){int n;while(~scanf("%d",&n)){for (int i = 0;i < n;i ++)scanf("%s%d%d",buf[i].name,&buf[i].age,&buf[i].score);sort(buf,buf + n); for (int i = 0;i < n;i ++)printf("%s %d %d\n",buf[i].name,buf[i].age,buf[i].score);} return 0; }另一种解题方法(用冒泡方法和快速排序)
http://blog.csdn.net/leizh007/article/details/8510025
- 九度教程--------2
- 九度教程--------1
- 九度教程--------3
- 九度教程--------4
- 九度教程--------5
- 九度教程--------6
- 九度教程--------7
- 九度教程--------8
- 九度教程--------9
- 九度教程--------10
- 九度教程--------11
- 九度教程--------12
- 九度教程--------13
- 九度教程---------15
- 九度教程---------14
- 九度教程--------19
- 九度教程---------20
- 九度教程--------21
- java基础 -- Java 类中各成分加载顺序 和 内存中的存放位置
- JS中的原型
- 九度教程--------1
- [Lubuntu]安装adb
- JQuery中get和getJSON方法返回json对象无法获取问题
- 九度教程--------2
- 九度教程--------3
- 整数的所有不同分割数目--非递归算法
- 批判思考小记1:正则表达式
- pat 1023
- C语言实现贪吃蛇
- “org.hibernate.exception.SQLGrammarException: could not insert...”解决方法
- linux-011调试教程,写了个readblock可以读取指定块号的块到文件
- VMware虚拟机下LINUX网络设置