kema

DrunkAni

Apr 21st, 2016
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 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.     class DrunkAni
  7.     {
  8.         static void Main()
  9.         {
  10.             long n = long.Parse(Console.ReadLine());
  11.             decimal[] numberOfCabins = new decimal[n];
  12.             long currentPosition = 0;
  13.             long totalLengthCovered = 0;
  14.             for (int i = 0; i < n; i++)
  15.             {
  16.                 numberOfCabins[i] = i;
  17.             }
  18.             string nextComand = Console.ReadLine();
  19.             while (nextComand!="Found a free one!")
  20.             {
  21.                 long oldPosition = currentPosition;
  22.                 currentPosition = (currentPosition+long.Parse(nextComand))%n;
  23.                 long difference = currentPosition - oldPosition;
  24.                 if (difference>0)
  25.                 {
  26.                     Console.WriteLine("Go {0} steps to the right, Ani.",difference);
  27.                 }
  28.                 else if (difference<0)
  29.                 {
  30.                     Console.WriteLine("Go {0} steps to the left, Ani.",Math.Abs(currentPosition - oldPosition));
  31.                 }
  32.                 else
  33.                 {
  34.                     Console.WriteLine("Stay there, Ani.");
  35.                 }
  36.                 totalLengthCovered += Math.Abs(currentPosition - oldPosition);
  37.                 nextComand = Console.ReadLine();
  38.  
  39.             }
  40.             Console.WriteLine("Moved a total of {0} steps.",totalLengthCovered);
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment