Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace _6.FourDigits
- {
- class fourDigits
- {
- static void Main()
- {
- int inputNumber = int.Parse(Console.ReadLine());//1234;
- int thousands = (inputNumber / 1000);
- int hundreds = (inputNumber / 100) % 10;
- int tenths = (inputNumber / 10) % 10;
- int units = (inputNumber % 10);
- int sumOfDigits = thousands + hundreds + tenths + units;
- Console.WriteLine(sumOfDigits);
- int reversedThousands = units;
- int reversedHundreds = tenths;
- int reversedTenths = hundreds;
- int reversedUnits = thousands;
- Console.WriteLine("{0}{1}{2}{3}", reversedThousands,reversedHundreds,reversedTenths,reversedUnits);
- Console.WriteLine("{0}{1}{2}{3}",units,thousands,hundreds,tenths);
- Console.WriteLine("{0}{1}{2}{3}",thousands,tenths,hundreds,units );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment