Advertisement
Guest User

Untitled

a guest
Feb 29th, 2020
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.32 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         struct Sportsmen
  8.         {
  9.             public string Name;
  10.             public double[] Scores;
  11.             public double Score;
  12.  
  13.  
  14.             public Sportsmen(string name)
  15.             {
  16.                 Name = name;
  17.                 Scores = new double[4];
  18.                 Score = 0.0;
  19.             }
  20.         }
  21.  
  22.         static void Main()
  23.         {
  24.             Sportsmen[] sportsmens = new[]
  25.             {
  26.                 new Sportsmen("Азеев"),
  27.                 new Sportsmen("Козак"),
  28.                 new Sportsmen("Кадирбеков"),
  29.                 new Sportsmen("Тимофеев"),
  30.                 new Sportsmen("Евгеньев")
  31.             };
  32.  
  33.             Random rnd = new Random();
  34.            
  35.  
  36.             for (int i = 0; i < sportsmens.Length; i++)
  37.             {
  38.                 for (int j = 0; j < 4; j++) // прыжки
  39.                 {
  40.                     double k = rnd.Next(15, 21) / 6.0;// коэффициент сложности прыжка
  41.                     int[] s = new int[7]; // оценки судей
  42.  
  43.                     for (int c = 0; c < 7; c++) // выставление оценочек
  44.                         s[c] = rnd.Next(1, 6);
  45.  
  46.                     int max = s[0], min = s[0]; // поиск лучшей и худшей оценочки
  47.                     for (int c = 0; c < 7; c++)
  48.                     {
  49.                         if (s[c] > max)
  50.                             max = s[c];
  51.                         if (s[c] < min)
  52.                             min = s[c];
  53.                     }
  54.  
  55.                     int sum = 0;
  56.                     for (int c = 0; c < 7; c++)
  57.                     {
  58.                         if (s[c] == max || s[c] == min) // не учитываем лучший и худший оценочку
  59.                             continue;
  60.  
  61.                         sum += s[c];
  62.                     }
  63.  
  64.                     sportsmens[i].Scores[j] = sum * k; // заносим результат спортсмену
  65.                 }
  66.             }
  67.  
  68.             for (int i = 0; i < sportsmens.Length; i++) // суммирование оценочек -> получение итоговой оценочки
  69.                 for (int j = 0; j < 4; j++)
  70.                     sportsmens[i].Score += sportsmens[i].Scores[j];
  71.  
  72.             for (int i = 0; i < sportsmens.Length; i++) // сортировка пузырьком
  73.             {
  74.                 for (int j = 0; j < sportsmens.Length - 1; j++)
  75.                 {
  76.                     if (sportsmens[j].Score < sportsmens[j + 1].Score)
  77.                     {
  78.                         // обмен переменных sportsmens[j + 1] и sportsmens[j]
  79.                         Sportsmen temp;
  80.                         temp = sportsmens[j + 1];
  81.                         sportsmens[j + 1] = sportsmens[j];
  82.                         sportsmens[j] = temp;
  83.                     }
  84.                 }
  85.             }
  86.  
  87.  
  88.             // Вывод таблицы
  89.             for (int i = 0; i < sportsmens.Length; i++)
  90.             {
  91.                 Console.Write("Фамилия\t{0, 15}\tРезультат\t{1:f2}", sportsmens[i].Name, sportsmens[i].Score);
  92.                 Console.WriteLine();
  93.             }
  94.         }
  95.     }
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement