Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace Histogramme
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- double p1 = 0;
- double p2 = 0;
- double p3 = 0;
- double p4 = 0;
- double p5 = 0;
- for (int i = 1; i <= n; i++)
- {
- int currentNumber = int.Parse(Console.ReadLine());
- if (currentNumber < 200)
- {
- p1++;
- }
- else if ((currentNumber >= 200) && (currentNumber <= 399))
- {
- p2++;
- }
- else if ((currentNumber >= 400) && (currentNumber <= 599))
- {
- p3++;
- }
- else if ((currentNumber >= 600) && (currentNumber <= 799))
- {
- p4++;
- }
- else if (currentNumber >= 800)
- {
- p5++;
- }
- }
- double pInRange1 = (p1 / n) * 100;
- double pInRange2 = (p2 / n) * 100;
- double pInRange3 = (p3 / n) * 100;
- double pInRange4 = (p4 / n) * 100;
- double pInRange5 = (p5 / n) * 100;
- Console.WriteLine($"{pInRange1:f2}%");
- Console.WriteLine($"{pInRange2:f2}%");
- Console.WriteLine($"{pInRange3:f2}%");
- Console.WriteLine($"{pInRange4:f2}%");
- Console.WriteLine($"{pInRange5:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement