Advertisement
viraco4a

Simple_Loops_Histograma

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