/**简单选择排序*/
#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的更多相关文章

  1. 三大基础排序算法BubbleSort、SelectSort、InsertSort

    public class Strategy { public static void main(String[] args) { int [] array=new int[]{26,25,15,42, ...

  2. 排序算法ONE:选择排序SelectSort

    /** *选择排序: * 对冒泡排序的一个改进 * 进行一趟排序时,不用每一次都交换,只需要把最大的标示记下 * 然后再进行一次交换 */ public class SelectSort { /** ...

  3. 选择排序SelectSort

    /** * * @author Administrator * 功能:选择排序法 */ package com.test1; import java.util.Calendar; public cla ...

  4. SelectSort 选择排序

    //SelectSort (( O(n²))) public class TestSelectSort { public int[] selectSortArray(int[] arr){ int m ...

  5. 数据结构基础(1) --Swap & Bubble-Sort & Select-Sort

    Swap的简单实现 //C语言方式(by-pointer): template <typename Type> bool swapByPointer(Type *pointer1, Typ ...

  6. 排序之选择排序(SelectSort)

    package com.sort; /* * 选择排序 * 把第一位与其他数进行比较,这样每轮比较都会出现一个最大值或最小值 * 根据需要让升序或降序排列 */ public class Select ...

  7. C#数据结构与算法系列(十九):选择排序算法(SelectSort)

    1.介绍 选择排序算法属于内部排序算法,是从欲排序的数据中,按指定的规则选出某一元素,再依规定交换位置达到排序的目的 时间复杂度:O(n^2) 双层for 2.思想 选择排序(select sorti ...

  8. python selectsort

    # -*- coding: utf-8 -*-"""------------------------------------------------- File Name ...

  9. js实现四大经典排序算法

    为了方便测试,这里写了一个创建长度为n的随机数组 function createArr(n) { var arr = []; while (n--) { arr.push(~~(Math.random ...

随机推荐

  1. Hadoop入门进阶步步高(二)-文件夹介绍

    二.Hadoop文件夹结构 这里重点介绍几个文件夹bin.conf及lib文件夹. 1.$HADOOP_HOME/bin文件夹 文件名 说明 hadoop 用于运行hadoop脚本命令,被hadoop ...

  2. [poj 2480] Longge's problem 解题报告 (欧拉函数)

    题目链接:http://poj.org/problem?id=2480 题目大意: 题解: 我一直很欣赏数学题完美的复杂度 #include<cstring> #include<al ...

  3. Error creating bean with name 'testController': Injection of resource dependencies failed;

    启动ssm项目报错: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 't ...

  4. Ajax的几种形式 和使用情况

    Ajax的几种形式: 1       $.get( "Login.ashx", {Name:name,Pwd:pwd,action:x}, function(data){这里用da ...

  5. vuejs scope

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  6. POJ 1320 Street Numbers(佩尔方程)

    Street Numbers Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 3078   Accepted: 1725 De ...

  7. Bootstrap modal.js 源码分析

    /* ======================================================================== * Bootstrap: modal.js v3 ...

  8. Playing With Stones UVALive - 5059 Nim SG函数 打表找规律

    Code: #include<cstdio> #include<algorithm> using namespace std; typedef long long ll; ll ...

  9. Git强制覆盖master分支

    在开发中,通常会保持两个分支master分支和develop分支,但是如果因为develop上面迭代太多而没有及时维护master,最后想丢弃master而直接将测试确认过的develop强推到mas ...

  10. 紫书 例题 10-24 UVa 1641(面积计算)

    遍历一遍,遇到边界为奇数次时,格子在多边形内 偶数次时,在多边形外 #include<cstdio> #define REP(i, a, b) for(int i = (a); i < ...