bacco

Игра на интервали

Feb 28th, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.23 KB | None | 0 0
  1. using System;
  2.  
  3. namespace КоледнаШапка
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             var gameTurns = int.Parse(Console.ReadLine());
  11.  
  12.             double points = 0;
  13.  
  14.             double first = 0;
  15.             double second = 0;
  16.             double third = 0;
  17.             double fourth = 0;
  18.             double fifth = 0;
  19.             double inval = 0;
  20.  
  21.             for (int i = 0; i <= gameTurns; i++)
  22.             {
  23.                 double turns = double.Parse(Console.ReadLine());
  24.  
  25.                 if (turns < 0 || 50 < turns)
  26.                 {
  27.                     inval++;
  28.                     points /= 2.0;
  29.                 }
  30.                 else if (turns < 10)
  31.                 {
  32.                     first++;
  33.                     points = points + turns * 0.20;}
  34.                 else if (turns < 20)
  35.                 {
  36.                     second++;
  37.                     points = points + turns * 0.30;
  38.                 }
  39.                 else if (turns < 30)
  40.                 {
  41.                     third++;
  42.                     points = points + turns * 0.40;
  43.                 }
  44.                 else if (turns < 40)
  45.                 {
  46.                     fourth++;
  47.                     points = points + 50;
  48.                 }
  49.                 else if (turns <= 50)
  50.                 {
  51.                     fifth++;
  52.                     points = points + 100;
  53.                 }
  54.                 if (i == gameTurns -1)
  55.                     break;
  56.             }
  57.  
  58.             Console.WriteLine($"{points:f2}");
  59.  
  60.             first = first / gameTurns * 100;
  61.             second = second / gameTurns * 100;
  62.             third = third / gameTurns * 100;
  63.             fourth = fourth / gameTurns * 100;
  64.             fifth = fifth / gameTurns * 100;
  65.             inval = inval / gameTurns * 100;
  66.  
  67.             Console.WriteLine($"From 0 to 9: {first:f2}%");
  68.             Console.WriteLine($"From 10 to 19: {second:f2}%");
  69.             Console.WriteLine($"From 20 to 29: {third:f2}%");
  70.             Console.WriteLine($"From 30 to 39: {fourth:f2}%");
  71.             Console.WriteLine($"From 40 to 50: {fifth:f2}%");
  72.             Console.WriteLine($"Invalid numbers: {inval:f2}%");
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment