sắp xếp chèn ( Insertion sort )
Bài giải : #include<iostream> #include<fstream> using namespace std; void doctep( float a[ 100 ], int & n) { ifstream doc( "output.txt" ); doc >> n; for ( int i = 0 ; i < n ; i ++ ) doc >> a[i]; } void ghi( float a[ 100 ], int n) { ofstream ghi( "sapxepchen.txt" ); ghi << "sap xep chen la: " ; for ( int i = 0 ; i < n; i ++ ) { ghi << a[i] << " " ; } } void doicho( float & x, float & y) { int tmp = x; x = y; y = tmp; } void chen( float N[ 100 ], int & n, int x, int i){ n = n + 1 ; for ( int j = n - 1 ; j > i; j -- ){ N[j] = N[j - 1 ]; } N[i] = x; } void sapxep( float a[ 100 ], int n){ float b[ 100 ]; int m = 0 ; b[ 0 ] = a[ 0 ]; m = 1 ; for ( int i = 1 ; i < n; i ++ ){ bool lonNhat = true; for ( int j = 0 ; j < m; j ++ ){ if (b[j] > a [i]){ cout << "chen " <...