Advertisement
knikolov98

Untitled

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