Advertisement
dakata

Division without remainder

Oct 10th, 2016
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CodingExam
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             var n = float.Parse(Console.ReadLine());
  10.  
  11.             short count2, count3, count4;
  12.             count2 = count3 = count4 = 0;
  13.  
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 var num = short.Parse(Console.ReadLine());
  17.                 if (num % 2 == 0) count2++;
  18.                 if (num % 3 == 0) count3++;
  19.                 if (num % 4 == 0) count4++;
  20.             }
  21.             Console.WriteLine("{0:f2}%", count2 / n * 100);
  22.             Console.WriteLine("{0:f2}%", count3 / n * 100);
  23.             Console.WriteLine("{0:f2}%", count4 / n * 100);
  24.         }
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement