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 Histogram
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int[] arr = new int[n];
- double a = 0.0;
- double b = 0.0;
- double c = 0.0;
- double d = 0.0;
- double e = 0.0;
- for (int i = 0; i < n; i++)
- {
- arr[i] = int.Parse(Console.ReadLine());
- }
- for (int i = 0; i < arr.Length; i++)
- {
- if (arr[i] >= 1 && arr[i] < 200)
- {
- a++;
- }
- else if (arr[i] >= 200 && arr[i] < 400)
- {
- b++;
- }
- else if (arr[i] >= 400 && arr[i] < 600)
- {
- c++;
- }
- else if (arr[i] >= 600 && arr[i] < 800)
- {
- d++;
- }
- else
- {
- e++;
- }
- }
- double p1 = (a / n) * 100;
- double p2 = (b / n) * 100;
- double p3 = (c / n) * 100;
- double p4 = (d / n) * 100;
- double p5 = (e / n) * 100;
- Console.WriteLine("{0:0.00}%", p1);
- Console.WriteLine("{0:0.00}%", p2);
- Console.WriteLine("{0:0.00}%", p3);
- Console.WriteLine("{0:0.00}%", p4);
- Console.WriteLine("{0:0.00}%", p5);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment