C++排序问题
来源:互联网 发布:excel2010数据验证 编辑:程序博客网 时间:2024/06/14 11:54
#include<stdio.h>#include<algorithm>using namespace std;int main(){ int n; int buf[10000]; while(scanf("%d",&n)!=EOF){ for(int i=0;i<n;i++){ scanf("%d",&buf[i]); } sort(buf,buf+n); for(int i=0;i<n;i++){ printf("%d ",buf[i]); } printf("\n"); }return 0;}//结构体排序#include<stdio.h>#include<algorithm>#include<string.h>using namespace std;struct E{ char name[100]; int age; int score;} buf[1000];bool cmp(E a,E b){ if(a.score!=b.score) return a.score<b.score; int tem=strcmp(a.name,b.name); if(tem!=0) return tem<0; else return a.age<b.age;}int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=0; i<n; i++) { scanf("%s%d%d",buf[i].name,&buf[i].age,&buf[i].score); } sort(buf,buf+n,cmp); for(int i=0; i<n; i++) { printf("%s %d %d\n",buf[i].name,buf[i].age,buf[i].score); } } return 0;}
阅读全文
0 0
- C语言排序问题
- c语言排序问题
- C++--车厢排序问题
- 问题 C: EXCEL排序
- 问题 C: 数字排序问题
- c之排序问题---插入排序详解
- c之排序问题---冒泡排序
- c代码--快速排序问题
- c代码--快速排序问题
- C语言程序设计排序问题 ~~求解
- 排序及问题(c)
- 数字排序问题(c++)
- C语言 1.排序问题
- c语言字符串排序问题
- 双链表排序问题(C语言)
- 象棋比赛问题(排序/C++)
- Objective-C学习-数组排序问题
- 问题 C: 结构体--学生信息排序
- 大创log01(07/18)
- 使用springmvc的MultipartFile实现单文件和多文件上传
- 接口与多态
- c语言中的#号和##号的作用
- zxing二维码生成
- C++排序问题
- ORBSlam2学习研究-Tracking流程
- 漫画算法:什么是 B+ 树?
- 自动化部署系统设计
- 数据库分库分表(sharding)系列—— 拆分实施策略和示例演示(2)
- iOS 点击按钮将文本复制到剪切板
- sass中转化为px转化为rem的使用
- oracle的FCB
- Shell系列—Shell 函数