Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _02._Odd_Occurrences
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int countFirst = 0; //броя на числата в група 1
- int countSecond = 0; //броя на числата в група 2
- int countThird = 0; //броя на числата в група 3
- for (int number = 1; number <= n; number++)
- {
- int value = int.Parse(Console.ReadLine());
- //проверка за група 1
- if (value % 2 == 0)
- {
- countFirst++;
- }
- //проверка за група 2
- if (value % 3 == 0)
- {
- countSecond++;
- }
- //проверка за група 3
- if (value % 4 == 0)
- {
- countThird++;
- }
- }
- //броят на числата във всяка група
- //процент = бр. / общ брой числа * 100
- double percentFirst = countFirst * 1.0 / n * 100;
- double percentSecond = countSecond * 1.0 / n * 100;
- double percentThird = countThird * 1.0 / n * 100;
- Console.WriteLine($"{percentFirst:F2}%");
- Console.WriteLine($"{percentSecond:F2}%");
- Console.WriteLine($"{percentThird:F2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement