CODE :
#include <iostream>
#define Max 100
using namespace std;
void selection_Sort (int A[] , int n){
int t;
for (int i = 0; i<(n-1); i++ ){
t = i;
for (int j = i+1; j<n ; j++ ){
if (A[j] < A[i]){
t = j;
}
}
int temp = A[i]; A[i] = A[t] ; A[t] = temp;
}
}
void Nhap (int A[],int &n){
cout << " so luong pt : "; cin >> n;
for (int i = 0; i<n; i++){
cin >> A[i] ;
}
}
void Xuat(int A[] , int n){
cout << " mang A : ";
for (int i = 0; i<n; i++){
cout << A[i] << " ";
}
}
int main (){
int A[Max], n;
Nhap(A,n);
selection_Sort(A,n);
Xuat(A,n);
return 0;
}
Nhận xét
Đăng nhận xét