Last active
October 20, 2015 13:33
-
-
Save omeroot/7562f372944f4df715a2 to your computer and use it in GitHub Desktop.
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
// | |
// main.c | |
// sort | |
// | |
// Created by Markakod Development on 20/10/15. | |
// Copyright (c) 2015 Markakod Development. All rights reserved. | |
// | |
#include <stdio.h> | |
void WTFSorting(int[], int); | |
void arr_swap(int[],int,int); | |
int size(int[]); | |
void WTFSorting(int *arr, int size) { | |
printf("size: %d\n",size); | |
int res[size]; | |
res[0] = arr[0]; | |
for(int i = 1 ; i< size ; i++){ | |
res[i] = arr[i]; | |
for(int j = 0 ; j < (sizeof(res) / sizeof(res[0]))-1 ; j++){ | |
if(arr[i] < res[j]){ | |
arr_swap(&res[0],i,j); | |
} | |
} | |
} | |
for(int i = 0 ; i< size ; i++){ | |
printf("%d ",res[i]); | |
} | |
printf("\n"); | |
} | |
void arr_swap(int* array,int index1,int index2){ | |
int temp = array[index1]; | |
array[index1] = array[index2]; | |
array[index2] = temp; | |
} | |
int main(){ | |
int val[5] = { 64, 32, 85, 24, 13 }; | |
int size = sizeof(val) / sizeof(val[0]); | |
WTFSorting(&(val[0]), size); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment