Advertisement
koksibg

Division

Jul 5th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.17 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 Division
  8. {
  9.     class Division
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             double Two = 0;
  15.             double Three = 0;
  16.             double Four = 0;
  17.             double TwoPercent = 0;
  18.             double ThreePercent = 0;
  19.             double FourPercent = 0;
  20.             bool a = (1 <= n) && (n <= 1000);
  21.             for (int i = 1; i <= n; i++)
  22.             {
  23.                 int number = int.Parse(Console.ReadLine());
  24.                 if ((number % 2 == 0) && a) Two++;
  25.                 if ((number % 3 == 0) && a) Three++;
  26.                 if ((number % 4 == 0) && a) Four++;
  27.                 if (Two != 0) TwoPercent = Two / n * 100;
  28.                 if (Three != 0) ThreePercent = Three / n * 100;
  29.                 if (Four != 0) FourPercent = Four / n * 100;
  30.             }
  31.             Console.WriteLine("{0:f2}" + "%", TwoPercent);
  32.             Console.WriteLine("{0:f2}"+ "%", ThreePercent);
  33.             Console.WriteLine("{0:f2}"+ "%", FourPercent);
  34.         }
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement