Bubble sort

PHOTO EMBED

Sun Apr 11 2021 15:56:01 GMT+0000 (UTC)

Saved by @dmatas #c

int main()
{
	int arr[5] = { 0 };
	int i = 0, j = 0, temp = 0;

	printf("Unesi 5 brojeva:\n");
	for (i = 0; i < 5; i++) {
		scanf(" %d", &arr[i]);
	}
	for (i = 0; i < 4; i++) {
		for (j = i + 1; j < 5; j++) {
			if (arr[i] > arr[j]) {
				temp = arr[i];
				arr[i] = arr[j];
				arr[j] = temp;
			}
		}
	}
	printf("------------\n");
	for (i = 0; i < 5; i++) {
		printf("%d\n", arr[i]);
	}
}
content_copyCOPY

Mjehurićasto sortiranje

https://www.tutorialspoint.com/data_structures_algorithms/bubble_sort_algorithm.htm