#include <stdio.h>voidMaopao (intArr[],intLen) { inttemp; //Double Loop for(intI=0; i<len-1; i++){ //because I's the value of each change once, ran a trip, according to bubbling thought//There's a number that's already sunk.//There is no need to compare with the already ordered data.//j<len-1-i; So j<len-1 can also, but more run will for(intj=0; j<len-1-I.; J + +) { if(arr[j]>arr[j+1]) { //values for interchange a[j] and a[j+1]//Add or Subtract xor temptemp =Arr[j]; ARR[J]= arr[j+1]; Arr[j+1] =temp; } } }}intMainintargcConst Char*argv[]) { inta[Ten]={1, $, at, $, A, the, +,4,388, the}; //A[0] 1//&a[0] Address//before sorting for(intI=0; i<Ten; i++) {printf ("%d\t", A[i]); } printf ("\ n"); //to sortMaopao (A,Ten);//the numbers are already in order.//iterating through an array for(intI=0; i<Ten; i++) {printf ("%d\t", A[i]); } return 0;}
"Mastering" Select Sort Code Implementation
#include <stdio.h>/** * Select sort*/voidSelectsort (intArr[],intLen) { //write a double loop// inttemp; for(intI=0; i<len-1; i++) { for(intj=i+1; j<len; J + +) { //basis of the Exchange// if(arr[i]>Arr[j]) { //allow Arr[i] and arr[j] to be exchangedtemp =Arr[i]; Arr[i]=Arr[j]; ARR[J]=temp; } } }}intMainintargcConst Char*argv[]) { //define an array inta[Ten]={ at, A,4, the, -, -, +, $,3, -}; //Purpose SortSelectsort (A,Ten); //traversing an output array for(intI=0; i<Ten; i++) {printf ("%d\t", A[i]); } return 0;}
3 4 a - + at - $ the -
<17> "Mastering" bubble Sort Code Implementation + "Mastering" Selection sorting code implementation