九度OJ1061成绩排序
来源:互联网 发布:surface laptop 知乎 编辑:程序博客网 时间:2024/05/18 04:05
九度OJ的一个网友遇到一个小问题,随便看了看找了出来,学ACM好多代码是C/C++混编的,其实对C++并不是很了解,有时间看看重载大于号的机制到底是怎么回事
先学会怎么用。
#include <iostream>#include <algorithm>#include <vector>#include <string>using namespace std;class StuInfo{ public: string strName; int nAge; int nScore; bool operator > ( const StuInfo &a ){ if( this->nScore > a.nScore )return true; else if( this->nScore < a.nScore )return false; else if( this->strName > a.strName )return true; else if(this ->strName < a.strName )return false; else if( this->nAge > a.nAge )return true; else return false; };};vector<StuInfo> StuList;int cmp( StuInfo a, StuInfo b ){ if ( a > b )return 0; else return 1;}int main( ){ int N; StuInfo buffer; while( cin >> N ){ StuList.clear(); for( int i = 0; i < N; i++ ){ cin >> buffer.strName >> buffer.nAge >> buffer.nScore; StuList.push_back( buffer ); } sort( StuList.begin(), StuList.end(), cmp ); for( vector<StuInfo>::iterator iter = StuList.begin(); iter < StuList.end(); ++ iter ){ cout << (*iter).strName << ' ' << (*iter).nAge << ' ' << (*iter).nScore <<endl; } } return 0;}
0 0
- 九度OJ1061成绩排序
- 九度1061 成绩排序
- 九度-1196-成绩排序
- 九度OJ 题目1196:成绩排序
- 【九度】题目1061:成绩排序
- 【九度】题目1196:成绩排序
- 九度OJ 1061: 成绩排序
- 九度题目1061:成绩排序
- 【王道九度OJ】1061成绩排序
- 九度OJ题目1061:成绩排序
- 九度OJ 题目1061:成绩排序
- 九度题目1061:成绩排序
- 【九度】题目1061:成绩排序
- 九度 OJ 1061:成绩排序
- 九度OJ 1061 成绩排序
- 九度OJ 1061 成绩排序
- 九度OJ-1061:成绩排序
- 题目1061:成绩排序 九度OJ
- 支付宝高可用系统架构-胡喜
- 黑马程序员-面向对象03
- Bus System hdu 1690 Floyd的基本
- 编写一个方法,返回某字符串的所有排列组合。
- VB中应用DDE
- 九度OJ1061成绩排序
- [经典]Linux内核中ioremap映射的透彻理解
- Merge Sorted Array
- 机房收费系统之可行性研究报告
- U-Boot与Linux内核的交互
- 获取scrollTop兼容各浏览器的方法
- [Python] Commands in Django
- winHttp库使用过程中总结的若干小问题
- hdu 1249 三角形 组合数学