NedyalkoKikov

Histogram

May 1st, 2016
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 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 Histogram
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int counter = 0;
  15. int counter1 = 0;
  16. int counter2 = 0;
  17. int counter3 = 0;
  18. int counter4 = 0;
  19. for (int i = 0; i < n; i++)
  20. {
  21. int inputnumber = int.Parse(Console.ReadLine());
  22. if (inputnumber < 200)
  23. {
  24. counter++;
  25.  
  26. }
  27. else if (inputnumber < 400)
  28. {
  29. counter1++;
  30.  
  31. }
  32. else if(inputnumber < 600)
  33. {
  34. counter2++;
  35.  
  36. }
  37. else if(inputnumber < 800)
  38. {
  39. counter3++;
  40.  
  41. }
  42. else
  43. {
  44. counter4++;
  45.  
  46. }
  47. }
  48. Console.WriteLine("{0:F2}%",(double)counter / n * 100);
  49. Console.WriteLine("{0:F2}%",(double)counter1 / n * 100);
  50. Console.WriteLine("{0:F2}%",(double)counter2 / n * 100);
  51. Console.WriteLine("{0:F2}%",(double)counter3 / n * 100);
  52. Console.WriteLine("{0:F2}%",(double)counter4 / n * 100);
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment