Advertisement
AlexJC

Histogram

Aug 27th, 2016
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 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 Histogram
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int input1 = int.Parse(Console.ReadLine());
  14. double p1 = 0.0;
  15. double p2 = 0.0;
  16. double p3 = 0.0;
  17. double p4 = 0.0;
  18. double p5 = 0.0;
  19.  
  20. for (int i = 0; i < input1; i++)
  21. {
  22. double num = double.Parse(Console.ReadLine());
  23.  
  24. if (num < 200) p1++;
  25. else if (num >= 200 && num <= 399) p2++;
  26. else if (num >= 400 && num <= 599) p3++;
  27. else if (num >= 600 && num <= 799) p4++;
  28. else if (num >= 800) p5++;
  29. }
  30. double r1 = p1 / input1 * 100;
  31. double r2 = p2 / input1 * 100;
  32. double r3 = p3 / input1 * 100;
  33. double r4 = p4 / input1 * 100;
  34. double r5 = p5 / input1 * 100;
  35.  
  36. Console.WriteLine("{0:F2}%", r1);
  37. Console.WriteLine("{0:F2}%", r2);
  38. Console.WriteLine("{0:F2}%", r3);
  39. Console.WriteLine("{0:F2}%", r4);
  40. Console.WriteLine("{0:F2}%", r5);
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement