Advertisement
bacco

Sum Reversed Numbers

Jun 5th, 2018
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.79 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5.  
  6. namespace SumReversedNumbers
  7. {
  8.     class MainClass
  9.     {
  10.         public static void Main(string[] args)
  11.         {
  12.             List<int> numbers = Console.ReadLine()
  13.                                        .Split(' ')
  14.                                        .Select(int.Parse)
  15.                                        .ToList();
  16.  
  17.             int sum = 0;
  18.  
  19.             for (int i = 0; i < numbers.Count ; i++)
  20.             {
  21.                 List<char> num = numbers[i]
  22.                                     .ToString()
  23.                                     .ToList();
  24.                 num.Reverse();
  25.                 sum += int.Parse(string.Join("", num));
  26.             }
  27.             Console.WriteLine(sum);
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement