Guest User

19. Хистограма

a guest
Feb 9th, 2018
159
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace ConsoleApp9
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. var n = int.Parse(Console.ReadLine());
  10.  
  11. double p1 = 0;
  12. double p2 = 0;
  13. double p3 = 0;
  14. double p4 = 0;
  15. double p5 = 0;
  16.  
  17. for (int i = 0; i < n; i++)
  18. {
  19. var number = int.Parse(Console.ReadLine());
  20.  
  21. if (number < 200)
  22. {
  23. p1 += 1;
  24. }
  25. else if (number < 400)
  26. {
  27. p2 += 1;
  28. }
  29. else if (number < 600)
  30. {
  31. p3 += 1;
  32. }
  33. else if (number < 800)
  34. {
  35. p4 += 1;
  36. }
  37. else if (number < 1000)
  38. {
  39. p5 += 1;
  40. }
  41. }
  42.  
  43. double p1Percent = p1 / n * 100;
  44. double p2Percent = p2 / n * 100;
  45. double p3Percent = p3 / n * 100;
  46. double p4Percent = p4 / n * 100;
  47. double p5Percent = p5 / n * 100;
  48.  
  49. Console.WriteLine(Math.Round(p1Percent, 2) + "%");
  50. Console.WriteLine(Math.Round(p2Percent, 2) + "%");
  51. Console.WriteLine(Math.Round(p3Percent, 2) + "%");
  52. Console.WriteLine(Math.Round(p4Percent, 2) + "%");
  53. Console.WriteLine(Math.Round(p5Percent, 2) + "%");
  54. }
  55. }
  56. }
RAW Paste Data