Created
August 5, 2020 04:28
-
-
Save harieamjari/9baabb7cd4302dcd85b14c1379a815c4 to your computer and use it in GitHub Desktop.
Slow sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(){ | |
int arr[] = {6, 2, 5, 1, 20, 12, 8, 3, 400, 13, 13, 32}; | |
int lenarr = 12; | |
int a = 0; | |
int b = 1; | |
int look; | |
int iterate = 0; | |
while (iterate != 100){ | |
while (a < lenarr){ | |
while (b < lenarr){ | |
look = arr[a]; | |
if (look < arr[b]){ | |
arr[a] = arr[b]; | |
arr[b] = look; | |
b++; | |
look = arr[b]; | |
} else b++; | |
} | |
a++; | |
b = 0; | |
} | |
b = 0; | |
a = 0; | |
iterate++; | |
} | |
for (int i = 0; i < lenarr; i++) | |
printf("%d\n", arr[i]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment