Advertisement
Jakobhorak28

Untitled

Mar 14th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1.         static void MinSort( ref int z1, ref int z2, ref int z3)
  2.         {
  3.             int min, met, max;
  4.             if ((z1 < z2) && (z2 < z3))
  5.             {
  6.                 min = z1;
  7.                 met = z2;
  8.                 max = z3 ;
  9.             }
  10.             else
  11.             {
  12.                 if ((z2 < z1) && (z1 < z3))
  13.                 {
  14.                     min = z2;
  15.                     met = z1;
  16.                     max = z3;
  17.                 }
  18.                 else
  19.                 {
  20.                     if ((z3 < z1) && (z1 < z2))
  21.                     {
  22.                         min = z3;
  23.                         met = z1;
  24.                         max = z2;
  25.                     }
  26.                     else
  27.                     {
  28.                         if ((z2 < z3) && (z3 < z1))
  29.                         {
  30.                             min = z2;
  31.                             met = z3;
  32.                             max = z1;
  33.                         }
  34.                         else
  35.                         {
  36.                             min = z3;
  37.                             met = z2;
  38.                             max = z1;
  39.                         }
  40.                     }
  41.                 }
  42.             }
  43.             z1 = min;
  44.             z2 = met;
  45.             z3 = max;
  46.         }
  47.  
  48.         static void Main(string[] args)
  49.         {
  50.             int eins, zwei, drei;
  51.             Console.Write("Zahl 1: ");
  52.             eins = Convert.ToInt32(Console.ReadLine());
  53.             Console.Write("Zahl 2: ");
  54.             zwei = Convert.ToInt32(Console.ReadLine());
  55.             Console.Write("Zahl 3: ");
  56.             drei = Convert.ToInt32(Console.ReadLine());
  57.             MinSort(ref eins, ref zwei, ref drei);
  58.             Console.Write("Kleinste: " + eins + " Zweitkleinste: " + zwei + " Drittkleinste: " + drei);
  59.             Console.ReadLine();
  60.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement