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 StudentsGrades
- {
- class StudentsGrades
- {
- static void Main(string[] args)
- {
- Console.Write("Въведете броя на оценките на студентите: ");
- int n = int.Parse(Console.ReadLine());
- Console.WriteLine("Въведете оценките на студент А: ");
- int[] A = FillArray(n);
- Console.WriteLine("Въведете оценките на студент В: ");
- int[] B = FillArray(n);
- int[] C = FillRanbNum(n);
- Console.WriteLine("Оценките на студент А са: ");
- PrintArray(A);
- Console.WriteLine("Оценките на студент В са: ");
- PrintArray(B);
- Console.WriteLine("Оценките на студент С са: ");
- PrintArray(C);
- int minA = Min(A);
- Console.WriteLine("Най - ниската оценка на студент А е: " + minA);
- int maxB = Max(B);
- Console.WriteLine("Най - високата оценка на студент B е: " + maxB);
- Console.WriteLine("Оценките на студент С, които са по - ниски от средното му аритметично са: ");
- AverageGrades(C);
- Console.WriteLine();
- double average = Average(A, B, C);
- Console.WriteLine("Средният успех на тримата студенти е: " + average);
- Console.ReadKey(true);
- }
- static int[] FillArray(int n)
- {
- int[] array = new int[n];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = int.Parse(Console.ReadLine());
- }
- return array;
- }
- static int[] FillRanbNum(int n)
- {
- Random rand = new Random();
- int[] array = new int[n];
- for (int i = 0; i < array.Length; i++)
- {
- array[i] = rand.Next(2, 7);
- }
- return array;
- }
- static void PrintArray(int[] array)
- {
- for (int i = 0; i < array.Length; i++)
- {
- Console.Write(array[i] + " ");
- }
- Console.WriteLine();
- }
- static int Min(int[] array)
- {
- int min = array[0];
- for (int i = 0; i < array.Length; i++)
- {
- if (min > array[i])
- {
- min = array[i];
- }
- }
- return min;
- }
- static int Max(int[] array)
- {
- int max = array[0];
- for (int i = 0; i < array.Length; i++)
- {
- if (max < array[i])
- {
- max = array[i];
- }
- }
- return max;
- }
- static double Sum(int[] array)
- {
- double sum = 0;
- for (int i = 0; i < array.Length; i++)
- {
- sum += array[i];
- }
- return sum;
- }
- static void AverageGrades(int[] array)
- {
- double average = Sum(array) / array.Length;
- for (int i = 0; i < array.Length; i++)
- {
- if (array[i] < average)
- {
- Console.Write(array[i] + " ");
- }
- }
- }
- static double Average(int[] arr1, int[] arr2, int[] arr3)
- {
- double average = (Sum(arr1) + Sum(arr2) + Sum(arr3)) / (3 * arr1.Length);
- return average;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement