Advertisement
Guest User

Untitled

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