Advertisement
silvana1303

division without remainder

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