Advertisement
Guest User

Untitled

a guest
Dec 9th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.54 KB | None | 0 0
  1. class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             Console.WriteLine("A:");
  6.             double A = double.Parse(Console.ReadLine());
  7.             Console.WriteLine("B:");
  8.             double B = double.Parse(Console.ReadLine());
  9.             Console.WriteLine("C:");
  10.             double C = double.Parse(Console.ReadLine());
  11.             SortInc3_2(ref A, ref B, ref C);
  12.             Console.WriteLine($"\n{A}\n{B}\n{C}");
  13.         }
  14.  
  15.         static void SortInc3(ref double A, ref double B, ref double C)
  16.         {
  17.             double min = Math.Min(A, Math.Min(B, C));
  18.             double max = Math.Max(A, Math.Max(B, C));
  19.             double mid = 0d;
  20.             if (A != min && A != max) mid = A;
  21.             if (B != min && B != max) mid = B;
  22.             if (C != min && C != max) mid = C;
  23.             A = min;
  24.             B = mid;
  25.             C = max;
  26.         }
  27.  
  28.         static void SortInc3_1(ref double A, ref double B, ref double C)
  29.         {
  30.             List<double> list = new List<double>();
  31.             list.Add(A);
  32.             list.Add(B);
  33.             list.Add(C);
  34.             list.Sort();
  35.             A = list[0];
  36.             B = list[1];
  37.             C = list[2];
  38.         }
  39.  
  40.         static void SortInc3_2(ref double A, ref double B, ref double C)
  41.         {
  42.             double[] arr = new double[3];
  43.             arr[0] = A;
  44.             arr[1] = B;
  45.             arr[2] = C;
  46.             Array.Sort(arr);
  47.             A = arr[0];
  48.             B = arr[1];
  49.             C = arr[2];
  50.         }
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement