IvetValcheva

05. Divide Without Remainder

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