fbinnzhivko

04.Деление без остатък

May 3rd, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.63 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.  
  8.         int p1 = 0;
  9.         int p2 = 0;
  10.         int p3 = 0;
  11.  
  12.         for (int i = 0; i < n; i++)
  13.         {
  14.             int k = int.Parse(Console.ReadLine());
  15.  
  16.             if (k % 2 == 0) { p1++; }
  17.             if (k % 3 == 0) { p2++; }
  18.             if (k % 4 == 0) { p3++; }
  19.         }
  20.         decimal x = ((decimal)p1 / (decimal)n) * 100;
  21.         decimal x1 = ((decimal)p2 / (decimal)n) * 100;
  22.         decimal x2 = ((decimal)(p3) / n) * 100;
  23.  
  24.         Console.WriteLine("{0:f2}%\n{1:f2}%\n{2:f2}%\n", x, x1, x2);
  25.     }
  26. }
Add Comment
Please, Sign In to add comment