Advertisement
knikolov98

Untitled

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