排序一个阵列等阵列以下? [英] sort one array and other array following?
本文介绍了排序一个阵列等阵列以下?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面是C ++示例
int a[1000] = {3,1,5,4}
int b[1000] = {7,9,11,3}
我如何使它所以如果我有点数组,数组b也是继阵列
how do i make it so if i sort array a, array b also following array a
例如
a[1000] = {1,3,4,5}
b[1000] = {9,7,3,11}
有可能使用排序功能
is it possible using sort function
sort(a,a+4)
也有几分数组b藏汉?
but also sort array b aswell ?
编辑:什么?如果有3阵列
edit: what if there are 3 arrays ?
推荐答案
,你可以使用对
和然后进行排序,使用一个数组比较特殊的仿函数,而不是默认的小于操作?
Instead of using two arrays, can you use an array of pair
s and then sort THAT using a special comparison functor rather than the default less-than operator?
这篇关于排序一个阵列等阵列以下?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文