stoychevamaria89

Untitled

Jun 14th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace FourDigits
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int[] numArray = new int[4];
  15. numArray[0] = (n / 1000) % 10;
  16. numArray[1] = (n / 100) % 10;
  17. numArray[2] = (n / 10) % 10;
  18. numArray[3] = n % 10;
  19.  
  20. var sum = numArray[0] + numArray[1] + numArray[2] + numArray[3];
  21.  
  22.  
  23. int[] reversed = new int[4];
  24. reversed[0] = numArray[3];
  25. reversed[1] = numArray[2];
  26. reversed[2] = numArray[1];
  27. reversed[3] = numArray[0];
  28.  
  29. int[] lastDigitFirst = new int[4];
  30. lastDigitFirst[0] = numArray[3];
  31. lastDigitFirst[1] = numArray[0];
  32. lastDigitFirst[2] = numArray[1];
  33. lastDigitFirst[3] = numArray[2];
  34.  
  35. int[] secondThirdExchange = new int[4];
  36. secondThirdExchange[0] = numArray[0];
  37. secondThirdExchange[1] = numArray[2];
  38. secondThirdExchange[2] = numArray[1];
  39. secondThirdExchange[3] = numArray[3];
  40.  
  41.  
  42. Console.WriteLine(string.Join("", numArray));
  43. Console.WriteLine(string.Join("", reversed));
  44. Console.WriteLine(string.Join("", lastDigitFirst));
  45. Console.WriteLine(string.Join("", secondThirdExchange));
  46. }
  47. }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment