C++选择排序法(Selection Sort)
来源:互联网 发布:sql查询在哪 编辑:程序博客网 时间:2024/06/03 19:24
// implementation of Selection Sort (C++)#include <iostream>using namespace std;void SwapTwo(int& a, int& b){ int temp=a; a=b; b=temp;}void SelectionSort(int arr[], int size){ for (int i=0; i<size;i++) { int SmallestNum = arr[i]; int SmallestIndex = i; for (int j=i; j<size; j++) { if (arr[j]<SmallestNum) { SmallestNum = arr[j]; SmallestIndex = j; } } SwapTwo(arr[i], arr[SmallestIndex]); }}int main(){ int nums[] = {3,45,7,78,45,23,56,56,1,2,43,28}; int size = sizeof(nums)/sizeof(int); SelectionSort (nums, size); for (int i=0;i<size;i++) { cout << nums[i] << " "; } cout << endl; return 0;}
0 0
- (C#)选择排序 Selection Sort
- 选择排序法 (Selection Sort)
- 选择排序(selection sort)
- 选择排序(Selection Sort)
- selection sort 选择排序
- 选择排序 Selection Sort
- 选择排序(Selection Sort)
- 选择排序(Selection Sort)
- 选择排序 (Selection Sort)
- 选择排序(Selection sort)
- 选择排序 (Selection sort)
- 选择排序Selection sort
- Selection Sort(选择排序)
- 选择排序(Selection Sort)
- Selection Sort选择排序
- selection sort 选择排序
- selection sort(选择排序)
- Selection sort 选择排序
- 笔记《版本控制之道--使用Git》
- JAVA统一路径名格式代码
- Git冲突分析和处理
- 自己的小项目-WEB服务器IP统计
- 微软:中国59%电脑销售前已感染恶软
- C++选择排序法(Selection Sort)
- sugarnms智和EPON网管系统
- Fragment继承类的简单解析
- linux基本命令收藏
- Eclipse中使用Struts2和Tomcat访问Hbase数据库
- 腾讯实习生面试后的一些感悟
- OutLook的临时文件存放位置/打开邮件附件修改并保存附件没有更改
- sed find grep协同作战,实现多文件字符串替换
- kernel: nf_conntrack: table full, dropping packet解决办法