BdW44222

Untitled

May 10th, 2020
192
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace loopsExercise4Th
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9.  
  10. int n = int.Parse(Console.ReadLine());
  11. int group1 = 0;
  12. int group2 = 0;
  13. int group3 = 0;
  14. int group4 = 0;
  15. int group5 = 0;
  16.  
  17. for (int number = 1; number <= n; number++)
  18. {
  19. int value = int.Parse(Console.ReadLine());
  20. if (value < 200)
  21. {
  22. group1++;
  23. }
  24. else if (value >= 200 && value <= 399)
  25. {
  26. group2++;
  27. }
  28. else if (value >= 400 && value <= 599)
  29. {
  30. group3++;
  31. }
  32. else if (value >= 600 && value <= 799)
  33. {
  34. group4++;
  35. }
  36. else if (value > 800)
  37. {
  38. group5++;
  39. }
  40.  
  41. }
  42. double percentGroup1 = group1 * 1.0 / n * 100;
  43.  
  44. double percentGroup2 = group2 * 1.0 / n * 100;
  45.  
  46. double percentGroup3 = group3 * 1.0 / n * 100;
  47.  
  48. double percentGroup4 = group4 * 1.0 / n * 100;
  49.  
  50. double percentGroup5 = group5 * 1.0 / n * 100;
  51.  
  52. //Да отпечатаме
  53.  
  54. Console.WriteLine($"{percentGroup1:F2}%");
  55. Console.WriteLine($"{percentGroup2:F2}%");
  56. Console.WriteLine($"{percentGroup3:F2}%");
  57. Console.WriteLine($"{percentGroup4:F2}%");
  58. Console.WriteLine($"{percentGroup5:F2}%");
  59. }
  60. }
  61. }
RAW Paste Data