Guest User

Untitled

a guest
Oct 20th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _6.FourDigits
  4. {
  5. class fourDigits
  6. {
  7. static void Main()
  8. {
  9. int inputNumber = int.Parse(Console.ReadLine());//1234;
  10.  
  11. int thousands = (inputNumber / 1000);
  12. int hundreds = (inputNumber / 100) % 10;
  13. int tenths = (inputNumber / 10) % 10;
  14. int units = (inputNumber % 10);
  15.  
  16. int sumOfDigits = thousands + hundreds + tenths + units;
  17. Console.WriteLine(sumOfDigits);
  18.  
  19. int reversedThousands = units;
  20. int reversedHundreds = tenths;
  21. int reversedTenths = hundreds;
  22. int reversedUnits = thousands;
  23. Console.WriteLine("{0}{1}{2}{3}", reversedThousands,reversedHundreds,reversedTenths,reversedUnits);
  24.  
  25. Console.WriteLine("{0}{1}{2}{3}",units,thousands,hundreds,tenths);
  26.  
  27. Console.WriteLine("{0}{1}{2}{3}",thousands,tenths,hundreds,units );
  28.  
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment