Created
February 21, 2014 18:42
-
-
Save Twelve0fNine/9140525 to your computer and use it in GitHub Desktop.
How to simply sort an Array
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
namespace Sort_Array | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int count; | |
Console.WriteLine("How many Numbers you like to sort?\n"); | |
count = Convert.ToInt32(Console.ReadLine()); | |
int[] arrNumbers = new int[count]; | |
for (int i = 0; i < count; i++) | |
{ | |
int j= i+1; | |
Console.WriteLine("Enter Number " + j); | |
arrNumbers[i] = Convert.ToInt32(Console.ReadLine()); | |
} | |
Array.Sort(arrNumbers); | |
Console.Clear(); | |
for (int i = 0; i < arrNumbers.Length; i++) | |
{ | |
int j = i + 1; | |
//Console.WriteLine("Nr."+j+ " is: "+arrNumbers[i]+"\n"); | |
Console.Write(arrNumbers[i] + " "); | |
} | |
Console.WriteLine("\n\nPress any Key to Exit ..."); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment