mattnguyen

Untitled

Feb 28th, 2021
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4.  
  5. namespace _28_02_21
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. int n = int.Parse(Console.ReadLine());
  12. int p1 = 0;
  13. int p2 = 0;
  14. int p3 = 0;
  15. int p4 = 0;
  16. int p5 = 0;
  17.  
  18.  
  19. for (int i = 0; i < n; i++)
  20. {
  21. int num = int.Parse(Console.ReadLine());
  22.  
  23.  
  24. if (num < 200)
  25. {
  26. p1++;
  27. }
  28. else if (num >= 200 && i <= 399)
  29. {
  30. p2++;
  31. }
  32. else if (num >= 400 && i <= 599)
  33. {
  34. p3++;
  35. }
  36. else if (num >= 600 && i <= 799)
  37. {
  38. p4++;
  39. }
  40. else if (num >= 800)
  41. {
  42. p5++;
  43. }
  44. }
  45.  
  46. Console.WriteLine($"{1.0*p1/n*100:f2}%");
  47. Console.WriteLine($"{1.0*p2/n*100:f2}%");
  48. Console.WriteLine($"{1.0*p3/n*100:f2}%");
  49. Console.WriteLine($"{1.0*p4/n*100:f2}%");
  50. Console.WriteLine($"{1.0*p5/n*100:f2}%");
  51.  
  52. }
  53. }
  54. }
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
Advertisement
Add Comment
Please, Sign In to add comment