文章标题
来源:互联网 发布:贴吧发广告软件 编辑:程序博客网 时间:2024/06/16 12:38
/*Name: *.cppAuthor: dawangDescription: 插入排序Date: 2017-10-18 16:24Copyright:*/#include <iostream>#include <vector>using namespace std;int main(){ vector<double> ivec; cout << "请输入数字, ctrl+z 结束" << endl; double num; while (cin >> num) { ivec.push_back(num); } for (vector<double>::iterator i = ivec.begin() + 1; i != ivec.end(); ++i) { double key = *i; for (vector<double>::iterator j = i - 1; j >= ivec.begin(); --j) { if (*j > key) *(j + 1) = *j; else { *(j + 1) = key; break; } // 由于vector的迭代器的数值不允许小于v.begin(), 否则出现中断vector iterator not dereferencable if (j == ivec.begin()) { *j = key; break; } } } for (vector<double>::iterator index = ivec.begin(); index != ivec.end(); ++index) { cout << *index << " "; } return 0;}
阅读全文
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- GitHub使用记录一:中文乱码问题
- 关于动物的抽象模拟器
- 顺序查找的java、python、go语言的实现
- Android7.0 View.post与Handler.post
- pat 1004---简单的建树+层次遍历
- 文章标题
- Python之异步IO( asyncio) 协程
- 开发文档的简要模板
- QT学习=====QPainter,PaintEvent,setRenderHint(防止图形走样)
- 通过CodeIgniter快速开发Web应用(视图)
- windows下,使用批处理文件运行python程序
- 点分治 模板 poj1714
- http相关的整理
- 安装lnmp并配置可允许远程连接mysql