tsvetelinapasheva

TsvetelinaPasheva/ForLoopExercise/05.DivideWithoutRemainder

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