Advertisement
Guest User

Nightmare on Code Street

a guest
Apr 8th, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.59 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class Nightmare
  5. {
  6.     static void Main()
  7.     {
  8.         string input = Console.ReadLine();
  9.         string[] splitInput = input.Select(c => c.ToString()).ToArray();
  10.         long[] array = Array.ConvertAll(splitInput, long.Parse);
  11.         long sum = 0;
  12.         long oddNumbers = 0;
  13.         for (int i = 0; i < array.Length; i++)
  14.         {
  15.             if (i % 2 != 0)
  16.             {
  17.                 oddNumbers += 1;
  18.                 sum += array[i];
  19.             }
  20.         }
  21.         Console.Write(oddNumbers + " " + sum);
  22.         Console.WriteLine();
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement