SHARE
TWEET

Sắp Xếp Chọn

xachetbay May 22nd, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<stdio.h>
  2. #include<conio.h>
  3. #define MAX 100
  4. void nhap(int arr[], int n){
  5.     for(int i = 0;i<n;i++){
  6.         printf("Nhap a[%d]: ",i+1);
  7.         scanf("%d", &arr[i]);
  8.     }
  9. }
  10. void xuat(int arr[], int n){
  11.     for(int i = 0;i<n;i++){
  12.         printf(" %d ",arr[i]);
  13.     }
  14. }
  15. void doicho(int &a, int &b){
  16.     int temp;
  17.     temp = a; a = b; b = temp;
  18. }
  19. void sapxepChon(int arr[], int n){
  20.     int i,j,min;
  21.     for(i = 0; i < n-1;i++){
  22.         min = i;
  23.         for(j = i+1;j<n;j++)
  24.             if(arr[j]<arr[min])
  25.             min = j;
  26.             doicho(arr[i],arr[min]);
  27.     }
  28. }
  29. int main(){
  30.     int a[MAX],n;
  31.     printf("Nhap so phan tu: "); scanf("%d",&n);
  32.     nhap(a,n);
  33.     printf("Mang vua nhap: \n");
  34.     xuat(a,n);
  35.     sapxepChon(a,n);printf("\n");
  36.     printf("Mang sau khi sap xep: \n");
  37.     xuat(a,n);
  38.     return 0;
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top