Advertisement
Res5ec7

Coding 101 Exam - 26 March 2016, Задача 04 - Деление без ост

Apr 11th, 2016
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.01 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Delenie_bez_Ostatak
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int n = int.Parse(Console.ReadLine());
  14.             int p1 = 0;
  15.             int p2 = 0;
  16.             int p3 = 0;
  17.             int current = 0;
  18.  
  19.             for (int i = 1; i <= n; i++)
  20.             {
  21.                 current = int.Parse(Console.ReadLine());
  22.                 if (current % 2 == 0)
  23.                 {
  24.                     p1++;
  25.                 }
  26.                 if (current % 3 == 0)
  27.                 {
  28.                     p2++;
  29.                 }
  30.                 if (current % 4 == 0)
  31.                 {
  32.                     p3++;
  33.                 }
  34.  
  35.             }
  36.  
  37.             Console.WriteLine("{0:f2}%", p1 / n * 100);
  38.             Console.WriteLine("{0:f2}%", p2 / n * 100);
  39.             Console.WriteLine("{0:f2}%", p3 / n * 100);
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement