Advertisement
simonradev

Хистограма

Sep 26th, 2016
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace practice
  4. {
  5.     class Program
  6.     {
  7.         public static void Main(string[] args)
  8.         {
  9.             ushort countNumbers = ushort.Parse(Console.ReadLine());
  10.             ushort sumOfAllP1 = 0;
  11.             ushort sumOfAllP2 = 0;
  12.             ushort sumOfAllP3 = 0;
  13.             ushort sumOfAllP4 = 0;
  14.             ushort sumOfAllP5 = 0;
  15.            
  16.            
  17.             for (int i=0; i<countNumbers; i++)
  18.             {
  19.                 ushort numberInput = ushort.Parse(Console.ReadLine());
  20.                
  21.                 switch (numberInput)
  22.                 {
  23.                         case (numberInput > 0 && numberInput < 200): sumOfAllP1 += 1 ; break;
  24.                         case (numberInput >= 200 && numberInput < 400): sumOfAllP2 += 1 ; break;
  25.                         case (numberInput >= 400 && numberInput < 600): sumOfAllP3 += 1 ; break;
  26.                         case (numberInput >= 600 && numberInput < 800): sumOfAllP4 += 1 ; break;
  27.                         case (numberInput >= 800 && numberInput < 1000): sumOfAllP5 += 1 ; break;
  28.                 }
  29.             }
  30.            
  31.             Console.WriteLine("P1 = {0:f2}%", (sumOfAllP1 / 20 * 100));
  32.             Console.WriteLine("P2 = {0:f2}%", (sumOfAllP2 / 20 * 100));
  33.             Console.WriteLine("P3 = {0:f2}%", (sumOfAllP3 / 20 * 100));
  34.             Console.WriteLine("P4 = {0:f2}%", (sumOfAllP4 / 20 * 100));
  35.             Console.WriteLine("P5 = {0:f2}%", (sumOfAllP5 / 20 * 100));
  36.            
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement