选择排序1
2021-09-29 12:15
标签:main void return bsp printf pre div 选择排序 include 思路:每次找出数组中最大的数,放到后面。 1 #include 2 3 int max_index(int a[], int len); 4 int main(void) 5 { 6 int a[] = { 2,45,6,12,87,34,90,24,23,11,65 }; 7 int len = sizeof(a) / sizeof(a[0]); 8 9 for (int i = len; i > 1; i--) 10 { 11 int t = a[i - 1]; 12 a[i - 1] = a[max_index(a, i)]; 13 a[max_index(a, i)] = t; 14 } 15 16 for (int i = 0; i a[ret]) 29 { 30 ret = i; 31 } 32 } 33 34 return ret; 35 } 选择排序1标签:main void return bsp printf pre div 选择排序 include 原文地址:https://www.cnblogs.com/2018jason/p/12020513.html
下一篇:02-css的选择器