Advertisement
Valantina

DivisionWithoutRemainder/Exam

Jun 13th, 2019
106
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 DivisionWithoutRemainder
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int n = int.Parse(Console.ReadLine());
  10.             double firstCounter = 0;
  11.             double secondCounter = 0;
  12.             double thirdCounter = 0;
  13.  
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 int num = int.Parse(Console.ReadLine());
  17.  
  18.                 if (num % 2 == 0)
  19.                 {
  20.                     firstCounter++;
  21.                 }
  22.                 if (num % 3 == 0)
  23.                 {
  24.                     secondCounter++;
  25.                 }
  26.                 if (num % 4 == 0)
  27.                 {
  28.                     thirdCounter++;
  29.                 }
  30.             }
  31.             double firstP = (firstCounter / n) * 100;
  32.             double secondP = (secondCounter / n) * 100;
  33.             double thirdP = (thirdCounter / n) * 100;
  34.  
  35.             Console.WriteLine($"{firstP:F2}%");
  36.             Console.WriteLine($"{secondP:F2}%");
  37.             Console.WriteLine($"{thirdP:F2}%");
  38.         }
  39.     }
  40.    
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement