simonradev

Хистограма

Sep 26th, 2016
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.23 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.                 if (numberInput > 200)
  22.                 {
  23.                     sumOfAllP1 += 1;
  24.                 }
  25.                 else if (numberInput >= 200 && numberInput < 400)
  26.                 {
  27.                     sumOfAllP2 += 1;
  28.                 }
  29.                 else if (numberInput >= 400 && numberInput < 600)
  30.                 {
  31.                     sumOfAllP3 += 1;
  32.                 }
  33.                 else if (numberInput >= 600 && numberInput < 800)
  34.                 {
  35.                     sumOfAllP4 += 1;
  36.                 }
  37.                 else
  38.                 {
  39.                     sumOfAllP5 += 1;
  40.                 }
  41.             }
  42.            
  43.             double p1 = (sumOfAllP1 / 20 * 100);
  44.             Console.WriteLine("P1 = {0:f2}%", p1);
  45.             double p2 = (sumOfAllP2 / 20 * 100);
  46.             Console.WriteLine("P2 = {0:f2}%", p2);
  47.             double p3 = (sumOfAllP3 / 20 * 100);
  48.             Console.WriteLine("P3 = {0:f2}%", p3);
  49.             double p4 = (sumOfAllP4 / 20 * 100);
  50.             Console.WriteLine("P4 = {0:f2}%", p4);
  51.             double p5 = (sumOfAllP5 / 20 * 100);
  52.             Console.WriteLine("P5 = {0:f2}%", p5);
  53.                     }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment