Compare commits
	
		
			2 Commits
		
	
	
		
			32f22232c4
			...
			c4b219c556
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| c4b219c556 | |||
| 4252fb6918 | 
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,2 @@ | |||||||
|  | *.exe | ||||||
|  | .vscode | ||||||
							
								
								
									
										49
									
								
								bubblesort/main.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								bubblesort/main.c
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,49 @@ | |||||||
|  | #include <stdio.h> | ||||||
|  | #include <stdlib.h> | ||||||
|  | 
 | ||||||
|  | #define ARRAYLENGTH 100 | ||||||
|  | 
 | ||||||
|  | void generateRandomArray(int *array) | ||||||
|  | { | ||||||
|  |     for (size_t i = 0; i < ARRAYLENGTH; i++) | ||||||
|  |     { | ||||||
|  |         array[i] = rand(); | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void printArrayContent(int *array) | ||||||
|  | { | ||||||
|  |     for (size_t i = 0; i < ARRAYLENGTH; i++) | ||||||
|  |     { | ||||||
|  |         printf("%d ", array[i]); | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     printf("\n"); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | void sortArray(int *array) | ||||||
|  | { | ||||||
|  |     for (size_t i = 0; i < ARRAYLENGTH - 1; i++ ) | ||||||
|  |     { | ||||||
|  |         for (size_t j = 0; j < ARRAYLENGTH - 1 - i; j++) | ||||||
|  |         { | ||||||
|  |            if (array[j] > array[j+1]) | ||||||
|  |            { | ||||||
|  |             int temp = array[j+1]; | ||||||
|  |             array[j+1] = array[j]; | ||||||
|  |             array[j] = temp; | ||||||
|  |            }       | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | int main(int argc, char *argv[]) | ||||||
|  | { | ||||||
|  |     int array[ARRAYLENGTH]; | ||||||
|  | 
 | ||||||
|  |     generateRandomArray(array);     | ||||||
|  |     sortArray(array); | ||||||
|  |     printArrayContent(array); | ||||||
|  |      | ||||||
|  |     return 1; | ||||||
|  | } | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user