博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
STL list sort
阅读量:4091 次
发布时间:2019-05-25

本文共 1260 字,大约阅读时间需要 4 分钟。

#include 
#include
#include
using namespace std;typedef list
IList;#ifdef DEBUGvoid print(const IList &list){
IList::const_iterator ite = list.begin(); for (; ite != list.end(); ++ite) {
cout << *ite << " "; }}#endifint main(){
IList s; s.push_back(7); s.push_back(6); s.push_back(5); s.push_back(4); s.push_back(3); s.push_back(2); s.push_back(1); s.push_back(0); IList carry; IList counter[64]; int fill = 0; int num = 0; while (!s.empty()) {
cout << "取第" << num << "个数据: fill = " << fill << endl; carry.splice(carry.begin(), s, s.begin()); int i = 0; while (i < fill && !counter[i].empty()) {
counter[i].merge(carry); carry.swap(counter[i++]); } carry.swap(counter[i]); if (i == fill) ++fill;#ifdef DEBUG //我自己加的计数 num++; //打印每次完的结果 for (int i = 0; i < fill; ++i) {
cout << i << "=="; print(counter[i]); cout << endl; } #endif } for (int i = 1; i < fill; ++i) counter[i].merge(counter[i - 1]); s.swap(counter[fill - 1]); getchar(); return 0;}

转载地址:http://qecii.baihongyu.com/

你可能感兴趣的文章
vue.js基础之 过滤器详解
查看>>
vue.js基础 之 过滤器分类及使用
查看>>
原生 APP 与 web APP的区别比较
查看>>
mpvue 中使用 axios 详解
查看>>
【git 版本控制】git 提交文件名为中文的文件时,显示数字的问题
查看>>
【小工具】提升开发效率:sourceTree for Mac 可视化 git 工具
查看>>
VS CODE 实用快捷键
查看>>
JS 垃圾回收机制解析
查看>>
js 引用类型 之 数组(Array)及常用方法汇总
查看>>
【前端面试的坑】HTML行内置换元素与非置换元素的区分
查看>>
【前端面试的坑】浏览器的渲染模式
查看>>
JS中如何判断一个数字是整数还是小数
查看>>
【JS 函数】递归函数 之 arguments.callee
查看>>
【JS 函数】JS闭包深入了解
查看>>
【react常见问题】Useless constructor no-useless-constructor报错
查看>>
JS中 target和currentTarget的区别
查看>>
安卓移动端固定在底部的按钮被软件盘顶上去的解决方案
查看>>
一篇文章搞懂前置机到底是什么
查看>>
深入理解埋点
查看>>
JS 纯函数及其应用
查看>>