Advertisement
EmoRz

Division

Jul 19th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Division
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var p1 = 0.0;
  10.             var p2 = 0.0;
  11.             var p3 = 0.0;
  12.  
  13.             var n = int.Parse(Console.ReadLine());
  14.  
  15.             for (int i = 1; i <= n; i++)
  16.             {
  17.                 var num = int.Parse(Console.ReadLine());
  18.                 if (num % 2==0)
  19.                 {
  20.                     p1++;
  21.                 }
  22.                 if (num % 3 == 0)
  23.                 {
  24.                     p2++;
  25.                 }
  26.                 if (num % 4 == 0)
  27.                 {
  28.                     p3++;
  29.                 }
  30.             }
  31.             var percent1 = p1 / n * 100;
  32.             var percent2 = p2 / n * 100;
  33.             var percent3 = p3 / n * 100;
  34.  
  35.             Console.WriteLine($"{percent1:f2}%");
  36.             Console.WriteLine($"{percent2:f2}%");
  37.             Console.WriteLine($"{percent3:f2}%");
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement