Advertisement
anon20016

Untitled

Oct 21st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. double s = 0;
  10. int n = int.Parse(Console.ReadLine());
  11. string[] p = Console.ReadLine().Split();
  12. int[] a = new int[p.Length];
  13. int[] c = new int[11];
  14. for (int i = 0; i < p.Length; i++)
  15. {
  16. a[i] = int.Parse(p[i]);
  17. s = s + a[i];
  18. }
  19. double sr = s / n;
  20. Console.WriteLine("1) Средняя оценка: " + sr.ToString());
  21. int[] b = new int[11];
  22. for (int i = 0; i < a.Length; i++)
  23. {
  24. b[a[i]]++;
  25. }
  26. int mx = 0;
  27. int mn = a[0];
  28. for (int i = 0; i < 10; i++)
  29. {
  30. for (int j = 0; j < b[i]; j++)
  31. {
  32. if (b[mx] < b[i])
  33. {
  34. mx = i;
  35. }
  36. if (b[mn] > b[i] && b[i] > 0)
  37. {
  38. mn = i;
  39. }
  40. }
  41. }
  42.  
  43. Console.WriteLine("Самая встречаемая - " + mx.ToString());
  44. Console.WriteLine("Самая редкая - " + mn.ToString());
  45. for (int i = 0; i < c.Length; i++)
  46. {
  47. c[i] = i;
  48. }
  49. for (int j = 0; j < b.Length; j++)
  50. {
  51. for (int i = 0; i < b.Length - 1; i++)
  52. {
  53. if (b[i] > b[i + 1])
  54. {
  55. int x = b[i];
  56. b[i] = b[i + 1];
  57. b[i + 1] = x;
  58.  
  59. x = c[i];
  60. c[i] = c[i + 1];
  61. c[i + 1] = x;
  62. }
  63. }
  64. }
  65.  
  66. for (int i = 0; i < b.Length; i++)
  67. {
  68. if (b[i] != 0)
  69. {
  70. Console.WriteLine(c[i].ToString() + " " + b[i].ToString());
  71. }
  72. }
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement