Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- struct Sportsmen
- {
- public string Name;
- public double[] Scores;
- public double Score;
- public Sportsmen(string name)
- {
- Name = name;
- Scores = new double[4];
- Score = 0.0;
- }
- }
- static void Main()
- {
- Sportsmen[] sportsmens = new[]
- {
- new Sportsmen("Азеев"),
- new Sportsmen("Козак"),
- new Sportsmen("Кадирбеков"),
- new Sportsmen("Тимофеев"),
- new Sportsmen("Евгеньев")
- };
- Random rnd = new Random();
- for (int i = 0; i < sportsmens.Length; i++)
- {
- for (int j = 0; j < 4; j++) // прыжки
- {
- double k = rnd.Next(15, 21) / 6.0;// коэффициент сложности прыжка
- int[] s = new int[7]; // оценки судей
- for (int c = 0; c < 7; c++) // выставление оценочек
- s[c] = rnd.Next(1, 6);
- int max = s[0], min = s[0]; // поиск лучшей и худшей оценочки
- for (int c = 0; c < 7; c++)
- {
- if (s[c] > max)
- max = s[c];
- if (s[c] < min)
- min = s[c];
- }
- int sum = 0;
- for (int c = 0; c < 7; c++)
- {
- if (s[c] == max || s[c] == min) // не учитываем лучший и худший оценочку
- continue;
- sum += s[c];
- }
- sportsmens[i].Scores[j] = sum * k; // заносим результат спортсмену
- }
- }
- for (int i = 0; i < sportsmens.Length; i++) // суммирование оценочек -> получение итоговой оценочки
- for (int j = 0; j < 4; j++)
- sportsmens[i].Score += sportsmens[i].Scores[j];
- for (int i = 0; i < sportsmens.Length; i++) // сортировка пузырьком
- {
- for (int j = 0; j < sportsmens.Length - 1; j++)
- {
- if (sportsmens[j].Score < sportsmens[j + 1].Score)
- {
- // обмен переменных sportsmens[j + 1] и sportsmens[j]
- Sportsmen temp;
- temp = sportsmens[j + 1];
- sportsmens[j + 1] = sportsmens[j];
- sportsmens[j] = temp;
- }
- }
- }
- // Вывод таблицы
- for (int i = 0; i < sportsmens.Length; i++)
- {
- Console.Write("Фамилия\t{0, 15}\tРезультат\t{1:f2}", sportsmens[i].Name, sportsmens[i].Score);
- Console.WriteLine();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement