Advertisement
Filkolev

NIghtmareOnCodeStreet

Aug 19th, 2014
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. using System;
  2. using System.Numerics;
  3.  
  4. class NightmareOnCodeStreet
  5. {
  6.     static void Main()
  7.     {
  8.         string input = Console.ReadLine();
  9.  
  10.         int count = 0;
  11.  
  12.         BigInteger sum = 0;
  13.  
  14.         for (int i = 0; i < input.Length; i++)
  15.         {
  16.             if (i % 2 == 1)
  17.             {              
  18.  
  19.                 if (input[i] > 47 && input[i] < 58)
  20.                 {
  21.                     sum += (input[i] - 48);
  22.                     count++;
  23.                 }
  24.                
  25.             }
  26.         }
  27.  
  28.         Console.Write("{0} {1}", count, sum);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement