Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace ConsoleTest
- {
- class ConsoleTest
- {
- static void Main()
- {
- int input = int.Parse(Console.ReadLine());
- int[] digits = input.ToString().ToCharArray().Select(x => (int)Char.GetNumericValue(x)).ToArray();
- int sumOfDigits = 0;
- for (int i = 0; i < digits.Length; i++)
- {
- sumOfDigits += digits[i];
- }
- Console.WriteLine("Sum of digits:" + sumOfDigits);
- Console.WriteLine("Reversed:" + digits[3] + digits[2] + digits[1] + digits[0]);
- Console.WriteLine("Last digit in front:" + digits[3] + digits[0] + digits[1] + digits[2]);
- Console.WriteLine("Exchange second and third digits:" + digits[0] + digits[2] + digits[1] + digits[3]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment