Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 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 Arrays_NewStart
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int target = int.Parse(Console.ReadLine());
  14.             int startingPoint = target - 30;
  15.             int jump = 0;
  16.             int counter = 0;
  17.             int failJumps = 0;
  18.  
  19.             while (jump < target && target >= 100 && target <= 300)
  20.             {
  21.  
  22.                 jump = int.Parse(Console.ReadLine());
  23.                 counter++;
  24.  
  25.                 if (jump > startingPoint && jump < target )
  26.                 {
  27.                     startingPoint += 5;
  28.                     failJumps = 0;
  29.                 }
  30.                 else
  31.                 {
  32.                     failJumps++;
  33.                 }
  34.                 if (failJumps == 3)
  35.                 {
  36.                     Console.WriteLine($"Tihomir failed at {startingPoint}cm after {counter} jumps.");
  37.                     break;
  38.                 }
  39.                 else if (jump > target)
  40.                 {
  41.                         Console.WriteLine($"Tihomir succeeded, he jumped over {startingPoint}cm after {counter} jumps.");
  42.                         break;
  43.                 }
  44.             }
  45.         }
  46.            
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement