Select Sort Algorithm
来源:互联网 发布:网络红女杨涛照片 编辑:程序博客网 时间:2024/05/16 14:47
//选择排序算法
#include <stdlib.h>#include <stdio.h>#include <math.h>#define max_num100#define SWAP(X, Y, TEMP)((TEMP = X), (X = Y), (Y = TEMP))int main(int argc, char *argv[]){int list[max_num];int i, j, num, min, temp;printf("Please input number:");scanf("%d", &num);if (num < 0 || num > max_num) {fprintf(stderr, "invalid data\n");exit(1);}for (i = 0; i < num; i++) {list[i] = rand() % 1000;printf("%d ", list[i]);}printf("\n");for (i = 0; i < num; i++) {min = i;for (j = i + 1; j < num; j ++) {if (list[j] < list[min])min = j;}SWAP(list[i], list[min], temp);}printf("After select sort result:\n");for (i = 0; i < num; i ++)printf("%d ", list[i]);printf("\n");}
0 0
- Sort Algorithm-->Select Sort
- select sort algorithm
- Select Sort Algorithm
- Algorithm intro - Select Sort
- sort algorithm
- sort algorithm
- Sort algorithm
- Sort Algorithm-->Bubble Sort
- 快速排序与快速选择算法(quick sort and quick select algorithm)
- select-sort
- Select Sort
- Select Sort
- Sort algorithm overview.
- quick sort algorithm
- insert sort algorithm
- Insertion sort algorithm
- Algorithm---Selection Sort
- Algorithm---Insert Sort
- ios开发视频
- 使用CGAffineTransform实现对控件的旋转
- brctl, vconfig
- 碎碎念
- IOS常用的简单动画
- Select Sort Algorithm
- Hadoop笔记本
- 移植libjpeg
- Java编程需要远离的特性
- 用ROS制作我们的机器人小车(二): 编码篇
- 『黑马程序员』---java--7K面试题--交通灯管理系统
- 2013总结
- 黑马程序员-jdk1.5新特性之增强for循环
- asm迁移到asm