www.ctrt.net > C语言编程 题目描述 使用选择排序法对数组元素进行...

C语言编程 题目描述 使用选择排序法对数组元素进行...

#include int main() {int n,i,j,k,t,a[20]; scanf("%d",&n); for(i=0;i

void sort(int a[], int n) { int i, j, t; for(i = 0; i < n - 1; i++) for(j = i + 1; j < n; j++) if(a[i] > a[j]) { t = a[i]; a[i] = a[j]; a[j] = t; } }

#include int main() {int n,i,j,t,a[20]; scanf("%d",&n); for(i=0;i

#include void main() { int a[10] = { 10,2,3,4,5,6,9,8,7,1 }; int i,j,t; for(j=0;j

#includevoid sorted(int a[],int n){ //选择法排序 int i,j,k,t; for(i=0;i

#includevoid Sort(int *a,int n) {int *p,*q,*v,t;for(p = a;p < a + n - 1;++p) {v = p;for(q = p + 1; q < a + n; ++q)if(*v > *q) v = q;if(*p != *v) {t = *p;*p = *v;*v = t;}}}void Show(int *a,int n) {int i;for(i = 0; i < n; ++i)pr...

#include #include #include #define LENGTH 10void get_array(int * array, int len);void bubble_sort(int * array, int len);void print_array(int * array, int len);int main(){ int array[LENGTH] = {0}; get_array(array, LENGTH); bubbl...

#include void sort(int a[],int n) { int i; int j; for(i=1;i

//选择排序算法,按从小到大顺序void select_sort(int *arr,int n){ int i,j,k; int tmp; for(i=0;i

#include "stdio.h" void sort(const int, int*); int main(int argc, char** argv) { int array[] = {5, 34, 54, 2, 54, 51, 543, 2}; int i = 0; int arraySize = sizeof(array)/sizeof(array[0]); sort(arraySize, array); for (i = 0; i < a...

网站地图

All rights reserved Powered by www.ctrt.net

copyright ©right 2010-2021。
www.ctrt.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com