直接代码:
//局部排序 partial_sort partial_sort_copy
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main(){
int a[]={1,4,7,2,5,8,3,6,9,10};
vector<int>v(a,a+10);
vector<int>vv(a,a+10);
vector<int>vvv(10);
partial_sort(v.begin(),v.begin()+4,v.end());//部分排序
for(vector<int>::iterator itera=v.begin();itera!=v.end();++itera){
cout<<*itera<<" ";
}
cout<<endl;
//partial_sort(v.begin(),v.end(),v.end());则部分排序退化为普通排序,但是比sort要慢
partial_sort(v.begin()+4,v.end(),v.end(),greater<int>());//前面四个从小到大,后面六个从大到小
copy(v.begin(),v.end(),ostream_iterator<int>(cout," "));
cout<<endl;
partial_sort_copy(vv.begin(),vv.begin()+4,vvv.begin(),vvv.begin()+4);
for(vector<int>::iterator it1=vvv.begin();it1!=vvv.begin()+4;++it1){
cout<<*it1<<" ";
}
cout<<endl;
partial_sort_copy(vv.begin()+4,vv.end(),vvv.begin()+4,vvv.end(),greater<int>());
for(vector<int>::iterator it2=vvv.begin();it2!=vvv.end();++it2){
cout<<*it2<<" ";
}
cout<<endl;
system("pause");
return 0;
}
//nth_element()
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<functional>
using namespace std;
int main(){
vector<int>v;
for(int i=3;i<8;++i){
v.push_back(i);
}
for(int j=2;j<7;++j){
v.push_back(j);
}
for(int z=1;z<6;++z){
v.push_back(z);
}
nth_element(v.begin(),v.begin()+3,v.end());
cout<<"the four lowest elements are:";//前四个最小的
copy(v.begin(),v.begin()+4,ostream_iterator<int>(cout," "));
cout<<endl;
nth_element(v.begin(),v.end()-4,v.end());
cout<<"the four highest elements are:";//后四个最大的
copy(v.end()-4,v.end(),ostream_iterator<int>(cout," "));
cout<<endl;
nth_element(v.begin(),v.begin()+3,v.end(),greater<int>());
cout<<"the four highest elements are:";//前四个最大的
copy(v.begin(),v.begin()+4,ostream_iterator<int>(cout," "));
cout<<endl;
system("pause");
return 0;
}
分享到:
相关推荐
partial_sort 是Rust版本的_rust_代码_下载
udimanber add(y,i) partial_sum(i)udimanber add(y,i) partial_sum(i)udimanber add(y,i) partial_sum(i)udimanber add(y,i) partial_sum(i)udimanber add(y,i) partial_sum(i)udimanber add(y,i) partial_sum(i)
Lawrence_C._Evans_Partial_Differential_Equations_Second_Edition
return if we had a whole number of words.
partial_differential_equations (Evans).djvu
PlanAhead_Tutorial_Partial_Reconfiguration
Week_9_Calculus_II_Partial_derivatives_2.pdf
This file is subject to the terms and conditions of the GNU General Public License. See the file COPYING in the main directory of this archive for more details.
python库。 资源全名:print_partial_datasets-0.2.3.tar.gz
局部阴影光伏曲线,多峰模型,输出曲线较好。
PV ARRAY PERFORMANCE UNDER PARTIAL SHADING AND NOVEL OPTIMIZATION TECHNIQUE FOR MPPT PPT
partial_fit_testing:测试局部拟合
资源分类:Python库 所属语言:Python 资源全名:pytorch_partial_crf-0.2.1-py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059
Lawrence_C._Evanns编写的偏微分方程第二版,电子版非扫描版,网络上搜不到。
有限元的经典教材
这是一本全面介绍常微分方程的书,其中给出了用C++,Java,Maple,Matlab等各种语言实现的解方程例子和分析过程。对于物理等专业应该很适用。
PV panel in matlab under partial shading
partial_sort_copy 对给定区间复制并排序 nth_element 找出给定区间的某个位置对应的元素 is_sorted 判断一个区间是否已经排好序 partition 使得符合某个条件的元素放在前面 stable_partition 相对稳定