Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DomashnoDevideWithhoutRemainder
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- // count numbers
- int p1 = 0; // /2
- int p2 = 0; // /3
- int p3 = 0; // /4
- for (int i = 0; i < n; i++)
- {
- int input = int.Parse(Console.ReadLine());
- if (input % 2 == 0)
- {
- p1++;
- }
- if (input % 3 == 0)
- {
- p2++;
- }
- if (input % 4 == 0)
- {
- p3++;
- }
- }
- // calculate percentage
- double p1Percent = 0.0;
- double p2Percent = 0.0;
- double p3Percent = 0.0;
- if (p1 > 0)
- {
- p1Percent = 1.00 * p1 / n * 100;
- }
- if (p2 > 0)
- {
- p2Percent = 1.00 * p2 / n * 100;
- }
- if (p3 > 0)
- {
- p3Percent = 1.00 * p3 / n * 100;
- }
- // print
- Console.WriteLine($"{p1Percent:f2}%");
- Console.WriteLine($"{p2Percent:f2}%");
- Console.WriteLine($"{p3Percent:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement