Advertisement
thegrudge

FourDigitNumber

Nov 11th, 2014
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.70 KB | None | 0 0
  1. using System;
  2. class FourDigitNumber
  3. {
  4.     static void Main()
  5.     {
  6.         int input = int.Parse(Console.ReadLine());  //2011
  7.         int fourthDigit = input % 10; // 201 >>1
  8.         int thirdDigit = (input / 10) % 10; // 20 >> 1
  9.         int secondDigit = (input / 100) % 10; //2 >> 0
  10.         int firstDigit = (input / 1000) % 10; //0 >> 2
  11.         Console.WriteLine(firstDigit+secondDigit+thirdDigit+fourthDigit);
  12.         Console.WriteLine("{3}{2}{1}{0}", firstDigit, secondDigit, thirdDigit, fourthDigit);
  13.         Console.WriteLine("{3}{0}{1}{2}", firstDigit, secondDigit, thirdDigit, fourthDigit);
  14.         Console.WriteLine("{0}{2}{1}{3}", firstDigit, secondDigit, thirdDigit, fourthDigit);
  15.  
  16.     }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement