Venciity

[SoftUni C# exam preparation] 02.AngryFemaleGPS

Apr 9th, 2014
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 KB | None | 0 0
  1. using System;
  2.  
  3. class AngryFemaleGPS
  4. {
  5.     static void Main()
  6.     {
  7.         string cordinateString = Console.ReadLine();
  8.         long countOdd = 0;
  9.         long countEven = 0;
  10.  
  11.         for (int i = 0; i < cordinateString.Length; i++)
  12.         {
  13.             if (char.IsDigit(cordinateString[i]))
  14.             {
  15.                 if (long.Parse(cordinateString[i].ToString()) % 2 == 1)
  16.                 {
  17.                     countOdd += long.Parse(cordinateString[i].ToString());
  18.                 }
  19.                 else
  20.                 {
  21.                     countEven += long.Parse(cordinateString[i].ToString());
  22.                 }
  23.             }
  24.         }
  25.  
  26.         if (countEven > countOdd)
  27.         {
  28.             Console.WriteLine("right {0}", countEven);
  29.         }
  30.         else if (countOdd > countEven)
  31.         {
  32.             Console.WriteLine("left {0}", countOdd);
  33.         }
  34.         else
  35.         {
  36.             Console.WriteLine("straight {0}", countOdd);
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment