Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- double s = 0;
- int n = int.Parse(Console.ReadLine());
- string[] p = Console.ReadLine().Split();
- int[] a = new int[p.Length];
- int[] c = new int[11];
- for (int i = 0; i < p.Length; i++)
- {
- a[i] = int.Parse(p[i]);
- s = s + a[i];
- }
- double sr = s / n;
- Console.WriteLine("1) Средняя оценка: " + sr.ToString());
- int[] b = new int[11];
- for (int i = 0; i < a.Length; i++)
- {
- b[a[i]]++;
- }
- int mx = 0;
- int mn = a[0];
- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < b[i]; j++)
- {
- if (b[mx] < b[i])
- {
- mx = i;
- }
- if (b[mn] > b[i] && b[i] > 0)
- {
- mn = i;
- }
- }
- }
- Console.WriteLine("Самая встречаемая - " + mx.ToString());
- Console.WriteLine("Самая редкая - " + mn.ToString());
- for (int i = 0; i < c.Length; i++)
- {
- c[i] = i;
- }
- for (int j = 0; j < b.Length; j++)
- {
- for (int i = 0; i < b.Length - 1; i++)
- {
- if (b[i] > b[i + 1])
- {
- int x = b[i];
- b[i] = b[i + 1];
- b[i + 1] = x;
- x = c[i];
- c[i] = c[i + 1];
- c[i + 1] = x;
- }
- }
- }
- for (int i = 0; i < b.Length; i++)
- {
- if (b[i] != 0)
- {
- Console.WriteLine(c[i].ToString() + " " + b[i].ToString());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement