Hàm sắp xếp các phần tử lẻ tăng dần trên mảng 1 chiều

void saptang(int a[], int n)
{
    int tam;
    for( int i=0;i<n-1;i++)
        if(a[i]%2==1)
            for( int j=i+1;j<n;j++)
            if (a[i]>a[j] && a[j]%2==1 )
            {
                     tam=a[i];
              a[i]=a[j];
              a[j]=tam;
            }
}

Share this

Related Posts

Previous
Next Post »