Advertisement
madeofglass

05. Division Without Remainder

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