Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cassert>
- int max( int a , int b )
- {
- if( a>b ) return a;
- else return b;
- assert(1);
- }
- void testMax()
- {
- assert( max(3,9)==9 );
- assert( max(9,3)==3 );
- }
- void swap( int *a , int *b )
- {
- int temp = *a;
- *a = *b;
- *b = temp;
- }
- void testSwap()
- {
- int a=8,b=2;
- swap(&a,&b);
- assert(a==2);
- assert(b==8);
- }
- void sort( int array[] , int size )
- {
- for( int i = 0 ; i < size-1 ; ++i )
- for( int j = i+1 ; j < size ; ++j )
- if( array[i] > array[j] )
- {
- int temp = array[i];
- array[i] = array[j];
- array[j] = temp;
- }
- }
- void testSort()
- {
- int arr[4] = {9,7,5,3};
- int result[4] = {3,5,7,9};
- sort(arr,4);
- for( int i = 0 ; i < 4 ; ++i )
- assert( arr[i] == result[i] );
- }
- int main()
- {
- testMax();
- testSwap();
- testSort();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement