Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace GameOfIntervals
- {
- class Program
- {
- static void Main(string[] args)
- {
- int num = int.Parse(Console.ReadLine());
- double result = 0;
- double num0To10 = 0;
- double num10To20 = 0;
- double num20To30 = 0;
- double num30To40 = 0;
- double num40To50 = 0;
- double numInvalid = 0;
- for (int i = 1; i <= num; i++)
- {
- double current = double.Parse(Console.ReadLine());
- if (current >= 0 && current < 10)
- {
- result += current * 0.2;
- num0To10++;
- }
- else if (current >= 10 && current < 20)
- {
- result += current * 0.3;
- num10To20++;
- }
- else if (current >= 20 && current < 30)
- {
- result += current * 0.4;
- num20To30++;
- }
- else if (current >= 30 && current < 40)
- {
- result += 50;
- num30To40++;
- }
- else if (current >= 40 && current <= 50)
- {
- result += 100;
- num40To50++;
- }
- else
- {
- result /= 2;
- numInvalid++;
- }
- }
- Console.WriteLine($"{ result:f2}");
- Console.WriteLine($"From 0 to 9: {num0To10 / num * 100:f2}%");
- Console.WriteLine($"From 10 to 19: { num10To20 / num * 100:f2}%");
- Console.WriteLine($"From 20 to 29: { num20To30 / num * 100:f2}%");
- Console.WriteLine($"From 30 to 39: { num30To40 / num * 100:f2}%");
- Console.WriteLine($"From 40 to 50: { num40To50 / num * 100:f2}%");
- Console.WriteLine($"Invalid numbers: { numInvalid / num * 100:f2}%");
- }
- }
Add Comment
Please, Sign In to add comment