Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Divide_Without_Remainder__For_Loop
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- double p1 = 0;
- double p2 = 0;
- double p3 = 0;
- for (int i = 1; i <= n; i++)
- {
- int currentNumber = int.Parse(Console.ReadLine());
- if (currentNumber % 2 == 0)
- {
- p1++;
- }
- if (currentNumber % 3 == 0)
- {
- p2++;
- }
- if (currentNumber % 4 == 0)
- {
- p3++;
- }
- }
- double pInRange1 = (p1 / n) * 100;
- double pInRange2 = (p2 / n) * 100;
- double pInRange3 = (p3 / n) * 100;
- Console.WriteLine($"{pInRange1:f2}%");
- Console.WriteLine($"{pInRange2:f2}%");
- Console.WriteLine($"{pInRange3:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement