Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace FourDigits
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int[] numArray = new int[4];
- numArray[0] = (n / 1000) % 10;
- numArray[1] = (n / 100) % 10;
- numArray[2] = (n / 10) % 10;
- numArray[3] = n % 10;
- var sum = numArray[0] + numArray[1] + numArray[2] + numArray[3];
- int[] reversed = new int[4];
- reversed[0] = numArray[3];
- reversed[1] = numArray[2];
- reversed[2] = numArray[1];
- reversed[3] = numArray[0];
- int[] lastDigitFirst = new int[4];
- lastDigitFirst[0] = numArray[3];
- lastDigitFirst[1] = numArray[0];
- lastDigitFirst[2] = numArray[1];
- lastDigitFirst[3] = numArray[2];
- int[] secondThirdExchange = new int[4];
- secondThirdExchange[0] = numArray[0];
- secondThirdExchange[1] = numArray[2];
- secondThirdExchange[2] = numArray[1];
- secondThirdExchange[3] = numArray[3];
- Console.WriteLine(string.Join("", numArray));
- Console.WriteLine(string.Join("", reversed));
- Console.WriteLine(string.Join("", lastDigitFirst));
- Console.WriteLine(string.Join("", secondThirdExchange));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment