Advertisement
ivan_yosifov

Nightmare_On_Code_Street

Dec 9th, 2013
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System;
  2.  
  3. class NightmareOnCodeStreet
  4. {
  5.     static void Main()
  6.     {
  7.         string number = Console.ReadLine();
  8.         int oddCount = 0;
  9.         int sum = 0;
  10.        
  11.         for (int i = 0; i < number.Length; i++)
  12.         {
  13.             char symbol = number[i];
  14.             if (char.IsDigit(symbol))
  15.             {
  16.                 char digit = symbol;
  17.                 if (i % 2 == 1)
  18.                 {
  19.                     oddCount++;
  20.                     sum += int.Parse(digit.ToString());
  21.                 }
  22.             }
  23.         }
  24.         Console.WriteLine("{0} {1}", oddCount, sum);
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement