If we want to sort an array containing numbers from smallest to biggest we can use the classic bubble sort algorithm. Here is its C implementation.
/* The classic bubble sort */ void bubbleSort( int A[], const int N ) { for( int i=0 ; i<(N-1); i++ ) { for( int j=0; j<(N-i-1); j++ ) { if( A[j]>A[j+1] ) { /* Swapping */ int swap = A[j]; A[j] = A[j+1]; A[j+1] = swap; } } } }
If we want to find an arrays maximum and minimum value we can use this simple algorithm. Here is its C implementation.
/* Find the max and min of an array */ void limits( const int A[], const int N, int* max, int* min ) { /* Assume min value */ *min = A[N-1]; *max = A[N-1]; /* For all */ for( int i = N-1; i>=0; i-- ) { /* Find min */ if( A[i] < *min ) { /* This is the new min */ *min = A[i]; } /* Find max */ if( A[i] > *max ) { /* This is the new min */ *max = A[i]; } } }
Remote repository:
ssh git@example.com mkdir my_project.git cd my_project.git git init --bare
Local repository:
cd my_project git init git add * git commit -m "Initial commit" git remote add origin example.com:my_project.git git push -u origin master