SelectSort
/**简单选择排序*/
#include<cstdio>
#include<algorithm>
using namespace std;
int a[]={5,2,1,3,4,6,8,9,10};
void f(int n){
for(int i=0;i<n;i++){
for(int j=i+1;j<n;j++)
if(a[j]<a[i]) swap(a[j],a[i]);
}
}
int main()
{
f(5);
for(int i=0;i<5;i++) printf("%d ",a[i]);
return 0;
}
SelectSort的更多相关文章
- 三大基础排序算法BubbleSort、SelectSort、InsertSort
public class Strategy { public static void main(String[] args) { int [] array=new int[]{26,25,15,42, ...
- 排序算法ONE:选择排序SelectSort
/** *选择排序: * 对冒泡排序的一个改进 * 进行一趟排序时,不用每一次都交换,只需要把最大的标示记下 * 然后再进行一次交换 */ public class SelectSort { /** ...
- 选择排序SelectSort
/** * * @author Administrator * 功能:选择排序法 */ package com.test1; import java.util.Calendar; public cla ...
- SelectSort 选择排序
//SelectSort (( O(n²))) public class TestSelectSort { public int[] selectSortArray(int[] arr){ int m ...
- 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort
Swap的简单实现 //C语言方式(by-pointer): template <typename Type> bool swapByPointer(Type *pointer1, Typ ...
- 排序之选择排序(SelectSort)
package com.sort; /* * 选择排序 * 把第一位与其他数进行比较,这样每轮比较都会出现一个最大值或最小值 * 根据需要让升序或降序排列 */ public class Select ...
- C#数据结构与算法系列(十九):选择排序算法(SelectSort)
1.介绍 选择排序算法属于内部排序算法,是从欲排序的数据中,按指定的规则选出某一元素,再依规定交换位置达到排序的目的 时间复杂度:O(n^2) 双层for 2.思想 选择排序(select sorti ...
- python selectsort
# -*- coding: utf-8 -*-"""------------------------------------------------- File Name ...
- js实现四大经典排序算法
为了方便测试,这里写了一个创建长度为n的随机数组 function createArr(n) { var arr = []; while (n--) { arr.push(~~(Math.random ...
随机推荐
- Mono源码学习笔记:Console类(四)
NullStream 类 (internal class) 以下就是 mcs/class/corlib/System.IO/NullStream.cs: 01: namespace System.IO ...
- Windows下Python2.7配置OpenCV2.4.10
所需文件: 1 Python2.7.13 链接: https://www.python.org/downloads/release/python-2713/ 这里选Windows 64位的安装包. 2 ...
- [Poj 1015] Jury Compromise 解题报告 (完全背包)
题目链接:http://poj.org/problem?id=1015 题目: 题解: 我们考虑设计DP状态(因为这很显然是一个完全背包问题不是吗?) dp[j][k]表示在外层循环到i时,选了j个人 ...
- ubuntu创建文件夹桌面快捷方式
最近在使用dropbox,用来存储一些自己的markdown笔记和pdf文件.觉得放一个快捷方式在桌面上比较方便,但是lxde似乎没有直接创建桌面快捷方式的功能(或者是我没有找到),就上网查了一下,顺 ...
- h5调用手机前后摄像头,拍照
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="pacam.aspx.cs& ...
- AlexNet (ImageNet模型)
介绍 AlexNet是LeNet的一种更深更宽的版本.首次在CNN中应用ReLU.Dropout和LRN,GPU进行运算加速. 一共有13层,有8个需要训练参数的层(不包括池化层和LRN层),前5层是 ...
- php重新编译,gd扩展支持jpeg文件
晚上写东西的时候,报了一个错误: Call to undefined function imagecreatefromjpeg() 没有开启 jpeg 支持?原来是默认安装的 gd 扩展默认不支持 j ...
- Lenovo k860i 移植Android 4.4 cm11进度记录【上篇已完结】
2014.5.16 为了验证一下下载的CM11的源码有没有问题,决定编译一下cm官方支持的机器,手上正好有台nexus7 2012,就拿它为例测试一下在mac os x平台的整个编译过程. 1. 最开 ...
- AP设备漫游阈值设置
在多个AP部署的场景下,默认情况下,手持移动设备(如PDA.手机)信号弱到断掉时才切换AP,无线信号很弱的情况下网络是非常的不稳定的,因此我们需要配置AP设备的漫游阈值(RSSI阈值),以便连接的无线 ...
- ZOJ 1654 Place the Robots (二分匹配 )
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=654 Robert is a famous engineer. One ...