Advertisement
metodievam

Untitled

Jun 3rd, 2017
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.52 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 test1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.  
  13.         {
  14.             int allseats = int.Parse(Console.ReadLine());
  15.             int allfans = int.Parse(Console.ReadLine());
  16.             int fansA = 0;
  17.             int fansB = 0;
  18.             int fansV = 0;
  19.             int fansG = 0;
  20.             double percA;
  21.             double percB = 0.0;
  22.             double percV = 0.0;
  23.             double percG = 0.0;
  24.             double percall = 0.0;
  25.  
  26.             for (int i = 1; i <= allfans; i++)
  27.             {
  28.                 string sector = Console.ReadLine();
  29.                
  30.                 switch (sector)
  31.                 {
  32.                   case "A": fansA = fansA + 1;break;
  33.                   case "B": fansB = fansB + 1;break;
  34.                   case "V": fansV = fansV + 1;break;
  35.                   case "G": fansG = fansG + 1;break;
  36.                 }
  37.             }
  38.             percA = (fansA / allfans) * 100;
  39.             percB = (fansB / allfans) * 100;
  40.             percV = (fansV / allfans) * 100;
  41.             percG = (fansG / allfans) * 100;
  42.             percall = (allfans / allseats) * 100;
  43.  
  44.             Console.WriteLine("{0:f2}", percA);
  45.             Console.WriteLine("{0:f2}", percB);
  46.             Console.WriteLine("{0:f2}", percV);
  47.             Console.WriteLine("{0:f2}", percG);
  48.             Console.WriteLine("{0:f2}", percall);
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement