c++ sort函数的用法
来源:互联网 发布:一句话经典 知乎 编辑:程序博客网 时间:2024/06/03 16:54
在c++中sort()函数计算的是在一定区间里的数字从小到大排列
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;long long a[100005];int cmp(int a,int b){ return a>b;}int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); } sort(a+1,a+n+1,cmp);//这个计算的是从大到小的排列 for(int i=1;i<=n;i++) { printf("%d\n",a[i]); } } return 0;}
#include<iostream>#include<cstdio>#include<algorithm>using namespace std;long long a[100005];int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=1;i<=n;i++) { scanf("%lld",&a[i]); } sort(a+1,a+n+1);//从小到大的排列 for(int i=1;i<=n;i++) { printf("%d\n",a[i]); } } return 0;}
阅读全文
0 0
- C++sort函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort()函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort函数的用法
- C++sort()函数的用法
- C++sort()函数的用法
- C++sort函数的用法
- c++sort函数的用法
- C++sort 函数用法
- C++sort 函数用法
- C++sort 函数用法
- PreferenceActivity
- NetBeans PHP 项目创建
- 并查集
- 对Java中的深复制和浅复制的一些理解
- 迷宫大门
- c++ sort函数的用法
- golang http 编程-1(服务器编程)
- Access denied for user 'root'@'%' to database 'ranger' ErrorCode: 1044
- 13、二叉搜索树-AVL树
- 正则表达式匹配
- 数据结构-循环列表
- python3.6+mysql无法写入中文问题
- DBMS_SHARED_POOL包将对象固定到共享池 .
- Java死锁问题分析