如何将这个数组首先排列所有0个元素,然后排列所有1个元素? [英] how will arrange this array first all 0 elements and then all 1 elements?

查看:81
本文介绍了如何将这个数组首先排列所有0个元素,然后排列所有1个元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的先生,

i在数组中有9个元素,如0 0 1 1 0 1 0 1 0现在我必须首先安排所有0个元素,然后是所有1个元素



我必须达到输出0 0 0 0 0 1 1 1 1





提前谢谢

Dear sir,
i have 9 elements in an array like 0 0 1 1 0 1 0 1 0 now i have to arrange first all 0 elements and then all 1 elements

and i have to achieve output like 0 0 0 0 0 1 1 1 1


thanks in advance

推荐答案

使用排序: http://stackoverflow.com/questions/1787996/c-library-function-to-do-sort [ ^ ]


这篇关于如何将这个数组首先排列所有0个元素,然后排列所有1个元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆