Advertisement
Svetli0o

AngryFemaleGPS

Apr 3rd, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.25 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. class Program
  8. {
  9.     static void Main(string[] args)
  10.     {
  11.         string n = Console.ReadLine();
  12.         long sumOddDigits = 0;
  13.         long sumEvenDigits = 0;
  14.         string direction = "";
  15.         for (int i = 0; i < n.Length; i++)
  16.         {
  17.             if (char.IsDigit(n[i]))
  18.             {
  19.                 if (Convert.ToInt64(n[i].ToString()) % 2 == 0)
  20.                 {
  21.                     sumEvenDigits += Convert.ToInt64(n[i].ToString());
  22.                 }
  23.                 else
  24.                 {
  25.                     sumOddDigits += Convert.ToInt64(n[i].ToString());
  26.                 }
  27.             }
  28.         }
  29.         if (sumEvenDigits > sumOddDigits)
  30.         {
  31.             direction = "right";
  32.             Console.WriteLine(direction + " " + sumEvenDigits);
  33.         }
  34.         else if (sumEvenDigits < sumOddDigits)
  35.         {
  36.             direction = "left";
  37.             Console.WriteLine(direction + " " + sumOddDigits);
  38.         }
  39.         else if (sumEvenDigits == sumOddDigits)
  40.         {
  41.             direction = "straight";
  42.             Console.WriteLine(direction + " " + sumEvenDigits);
  43.         }
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement