Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
782 B
5
Indexable
Never
#include <stdio.h>
#include <stdlib.h>
// 2 4 3 1
void nhap(int a[], int n){
    for (int i = 0; i < n; i++)
        scanf("%d",&a[i]);
}

void in(int a[],int n){
    for (int i = 0; i < n; i++)
        printf("a[%d]= %d \n",i,a[i]);
}

void swap(int &a , int &b){
    int tam = a;
    a = b;
    b = tam;
}

void sapxep(int a[], int n){
    for (int i = 0 ; i < n-1; i++)
    {
        int bd = i;
        for (int j = i+1; j<n; j++)
            if (a[j] < a[bd])
                bd  =j;
        swap(a[bd],a[i]);
    }
}

int main(){
    int a[1000];
    int n;
    printf("nhap so phan tu cua mang: ");
    scanf("%d",&n);

    nhap(a,n);
    printf("---mang da duoc sap xep--- \n");
    in(a,n);

    printf("%d",a);

    return 0;
}