Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace cslab4
- {
- class Program
- {
- static void Main(string[] args)
- {
- int studQty;
- Console.Write("Введите количество студентов в группе: ");
- studQty = Int32.Parse(Console.ReadLine());
- if (studQty < 0)
- throw new SystemException("Количество студентов не может быть отрицательным");
- string[] studNames = new string[studQty];
- for (int i = 0; i < studQty; i++)
- {
- Console.Write( $"Введите фамилию {i+1}-го студента: ");
- studNames[i] = Console.ReadLine();
- }
- Random rng = new Random();
- int[][] marks = new int[studQty][];
- for(int i = 0; i < studQty; i++)
- {
- marks[i] = new int[rng.Next(2, 9)];
- for (int j = 0; j < marks[i].Length; j++)
- marks[i][j] = rng.Next(1, 11);
- }
- Console.WriteLine("Баллы студентов");
- for(int i = 0; i < studQty; i++)
- {
- Console.WriteLine($"Оценки студента {studNames[i]}: ");
- foreach (int mark in marks[i])
- Console.Write($"{mark} ");
- Console.WriteLine();
- }
- for (int i = 0; i < studQty; i++)
- Console.WriteLine($"Сумма баллов студента {studNames[i]}: {sum(marks[i])}");
- showRating(marks);
- }
- public static int sum(params int[] arr)
- {
- int sum = 0;
- foreach (int elem in arr)
- sum += elem;
- return sum;
- }
- public static double sum(params double[] arr)
- {
- double sum = 0;
- foreach (double elem in arr)
- sum += elem;
- return sum;
- }
- public static void showRating(params int[][] marks)
- {
- int[] ratings = new int[marks.Length];
- for (int i = 0; i < ratings.Length; i++)
- {
- ratings[i] = sum(marks[i]);
- //Console.WriteLine($"{i + 1} : {ratings[i]} ");
- }
- Console.WriteLine($"Средний рейтинг группы: {(double)sum(ratings) / ratings.Length}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement