Advertisement
veselka_a

5.DivisionWithoutRemainder

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