Advertisement
alexbancheva

Divide_Without_Remainder

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