VC++ 中的排序

[复制链接]
查看11 | 回复1 | 2006-2-9 18:30:57 | 显示全部楼层 |阅读模式
#include #include using namespace std;bool func(const string &a,const string &b){ ...//当a<b时return true否则false}int main(){ string a[100]; sort(a,a+100);//对整个数组排序 sort(a,a+20);//对前十个string排序 sort(a,a+100,func);//实现自定义的排序,从小到大}
回复

使用道具 举报

千问 | 2006-2-9 18:30:57 | 显示全部楼层
使用STL的vector来存储这些string的指针然后使用排序函数sort(iter_begin, iter_end, sort_func)来排序就可以了
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行