Skip to content

Instantly share code, notes, and snippets.

@harieamjari
Created August 5, 2020 04:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harieamjari/9baabb7cd4302dcd85b14c1379a815c4 to your computer and use it in GitHub Desktop.
Save harieamjari/9baabb7cd4302dcd85b14c1379a815c4 to your computer and use it in GitHub Desktop.
Slow sort
#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