Created
February 13, 2013 03:52
-
-
Save yemaw/4942116 to your computer and use it in GitHub Desktop.
Manually Sort Integer Array
This file contains hidden or 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
using System; | |
class ManualIntegerArraySorting | |
{ | |
public static void Main() { | |
int[] arr = new int[10]{5,3,9,5,4,1,3,56,234,1}; | |
int smallest, pointer, tmp; | |
for(int i=0; i<10; i++){ | |
} | |
for (int index = 0; index < 10; index++) { | |
smallest = arr[index]; | |
pointer = index+1; | |
while(pointer<10){ | |
if(smallest > arr[pointer]){ | |
tmp = smallest; | |
smallest = arr[pointer]; | |
arr[pointer] = tmp; | |
} | |
pointer++; | |
} | |
arr[index] = smallest; | |
} | |
for (int k = 0; k < 10; k++) { | |
Console.WriteLine(arr[k]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment