aber ja doch :
der witz besteht darin, die ints in eine
List<int> zu packen.
weiterhin gibt es
List<T>.Sort(). somit sind alle probleme gelöst.
das sortieren an sich hat
immer was mit listen (oder arrays) zu tun!
wenn du lernen möchtest, wie man selbst listen/array sortiert, google nach bubblesort und quicksort.
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace simpleSort {
class Program {
static void Main(string[] args) {
List<int> liste = new List<int>();
Console.WriteLine("Zahlen eingeben, -1 für Ende\r\n");
string s = "";
while (s != "-1") {
Console.Write("> ");
s = Console.ReadLine();
if (s != "-1") {
try {
liste.Add(Int32.Parse(s));
}
catch (Exception ex) {
Console.WriteLine("das war wohl keine zahl! (" + ex.ToString() + ")");
}
}
}
liste.Sort();
foreach (int i in liste) {
Console.WriteLine(i);
}
Console.ReadLine();
}
}
}