Advertisement
Niicksana

Деление без остатък

Dec 3rd, 2017
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.22 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 Division
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Coding 101 Exam - 26 March 2016
  14.             int n = int.Parse(Console.ReadLine());
  15.  
  16.             double contP1 = 0;
  17.             double contP2 = 0;
  18.             double contP3 = 0;
  19.  
  20.             for (int num = 1; num <= n; num++)
  21.             {
  22.                 int currentNum = int.Parse(Console.ReadLine());
  23.                
  24.                 if (currentNum % 4 == 0)
  25.                 {
  26.                     contP3++;
  27.                 }
  28.                
  29.                 if (currentNum % 3 == 0)
  30.                 {
  31.                     contP2++;
  32.                 }
  33.  
  34.                 if (currentNum % 2 == 0)
  35.                 {
  36.                     contP1++;
  37.                 }
  38.  
  39.             }
  40.  
  41.             double p1 = (contP1 * 100.00) / n;
  42.             double p2 = (contP2 * 100.00) / n;
  43.             double p3 = (contP3 * 100.00) / n;
  44.  
  45.             Console.WriteLine(string.Format("{0:f2}%", p1));
  46.             Console.WriteLine(string.Format("{0:f2}%", p2));
  47.             Console.WriteLine(string.Format("{0:f2}%", p3));
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement