Search
 
SCRIPT & CODE EXAMPLE
 

C

how to sort an int array in c

void swap(int* xp, int* yp)
{
    int temp = *xp;
    *xp = *yp;
    *yp = temp;
}
 
// Function to perform Selection Sort
void selectionSort(int arr[], int n)
{
    int i, j, min_idx;
 
    // One by one move boundary of unsorted subarray
    for (i = 0; i < n - 1; i++) {
 
        // Find the minimum element in unsorted array
        min_idx = i;
        for (j = i + 1; j < n; j++)
            if (arr[j] < arr[min_idx])
                min_idx = j;
 
        // Swap the found minimum element
        // with the first element
        swap(&arr[min_idx], &arr[i]);
    }
}

// n is the size of the array
Comment

PREVIOUS NEXT
Code Example
C :: imprimir matriz 
C :: pandoc set margins pdf 
C :: C program to input the month number and output the month name using switch statement 
C :: unpack and repack deb package 
C :: leggere stringhe con spazio in mezzo c 
C :: delay in c programming for linux 
C :: c memcpy 
C :: user define function in c 
C :: stddef.h 
C :: prime numbers 
C :: print 0 1 2 3 4 in c while loop 
C :: struct in struct 
C :: oracle trunc 
C :: english to russian translation 
C :: how to declare a struct in c 
C :: c get pid 
C :: allintext:christie kiser filetype:log 
C :: allocating memory for 1Mb text file in C 
C :: dev c online 
C :: Fibonacci program c pthread 
C :: c program to pass a single element in an funtional array 
C :: how to stop aws alb temporarily 
C :: disable gnu++11 option 
C :: change data type inline in c 
C :: (avar == 1) ? (bvar == 2 ? result = 3 : (result = 5);) : (result = 0); 
C :: shortest job first 
C :: panagram in c 
C :: string compare in c 
C :: gotoxy not working in dev c++ 
C :: c printf float value 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =