anizko

05. Histogram

Apr 10th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 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 countNum = int.Parse(Console.ReadLine());
  14.             double Counter0 = 0;
  15.             double Counter200 = 0;
  16.             double Counter400 = 0;
  17.             double Counter600 = 0;
  18.             double Counter800 = 0;
  19.            
  20.  
  21.             for (int i=1;i<= countNum;i++)
  22.             {
  23.                 double Num = double.Parse(Console.ReadLine());
  24.  
  25.                 if (Num < 200)
  26.                 {
  27.                     Counter0++;
  28.                 }
  29.                 else if(Num >= 200&& Num<400)
  30.                 {
  31.                     Counter200++;
  32.                 }
  33.                 else if (Num >= 400 && Num < 600)
  34.                 {
  35.                     Counter400++;
  36.                 }
  37.                 else if (Num >= 600 && Num < 800)
  38.                 {
  39.                     Counter600++;
  40.                 }
  41.                 else if (Num >= 800)
  42.                 {
  43.                     Counter800++;
  44.                 }
  45.             }
  46.  
  47.             double Procent0 = Counter0 * 100 / countNum;
  48.             double Procent200 = Counter200*100 / countNum;
  49.             double Procent400 = Counter400 * 100 / countNum;
  50.             double Procent600 = Counter600 * 100 / countNum;
  51.             double Procent800 = Counter800 * 100 / countNum;
  52.  
  53.  
  54.             Console.WriteLine($"{Procent0:f2}%");
  55.             Console.WriteLine($"{Procent200:f2}%");
  56.             Console.WriteLine($"{Procent400:f2}%");
  57.             Console.WriteLine($"{Procent600:f2}%");
  58.             Console.WriteLine($"{Procent800:f2}%");
  59.  
  60.  
  61.  
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment