Advertisement
milislavski

NightmareOnCodeStreet

Apr 21st, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | None | 0 0
  1. using System;
  2.  
  3. class NightmareOnCodeStreet
  4. {
  5.     static void Main()
  6.     {
  7.         string inputText = Console.ReadLine();
  8.         int counterOfDigits = 0;
  9.         int sum = 0;
  10.         for (int i = 1; i < inputText.Length; i += 2)
  11.         {
  12.             if (inputText[i] >= '0' && inputText[i] <= '9' )
  13.             {
  14.                 sum += inputText[i] - '0';
  15.                 counterOfDigits++;
  16.             }
  17.         }
  18.         Console.WriteLine("{0} {1}", counterOfDigits, sum);
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement