Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace tESt
- {
- class Program
- {
- static void Main(string[] args)
- {
- var numStudents = int.Parse(Console.ReadLine());
- var car = 0; // >= 5
- var van = 0; // >=12
- var bus = 0; // >=25
- var doubleBus = 0; // >=40
- var train = 0; // < 40
- for (int i = 0; i < numStudents; i++)
- {
- var numGroup = int.Parse(Console.ReadLine());
- if (numGroup <= 5)
- {
- car += numGroup;
- }
- else if (numGroup <= 12)
- {
- van += numGroup;
- }
- else if (numGroup <= 25)
- {
- bus += numGroup;
- }
- else if (numGroup <= 40)
- {
- doubleBus += numGroup;
- }
- else if (numGroup > 40)
- {
- train += numGroup;
- }
- }
- double totalStudents = car + van + bus + doubleBus + train;
- var carPorcentage = (car / totalStudents) * 100;
- var vanPorcentage = van / totalStudents * 100;
- var busPorcentage = bus / totalStudents * 100;
- var doubleBusPorcentage = doubleBus / totalStudents * 100;
- var trainPorcentage = train / totalStudents * 100;
- Console.WriteLine($"{carPorcentage:f2}%");
- Console.WriteLine($"{vanPorcentage:f2}%");
- Console.WriteLine($"{busPorcentage:f2}%");
- Console.WriteLine($"{doubleBusPorcentage:f2}%");
- Console.WriteLine($"{trainPorcentage:f2}%");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment