Advertisement
SkeptaProgrammer

Untitled

Oct 23rd, 2016
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApplication3
  4. {
  5. class Program
  6. {
  7. public static string Numstr, Invertstr = "";
  8.  
  9. static void Main(string[] args)
  10. {
  11.  
  12. }
  13.  
  14. public static void ReadAndCheck()
  15. {
  16.  
  17. Numstr = Console.ReadLine();
  18. for (var i = 0; i < Numstr.Length - 1; i++)
  19. Invertstr += Numstr.Substring(Numstr.Length - i, 1);
  20. if (Numstr == Invertstr)
  21. {
  22. Console.WriteLine("Число является палиндромом");
  23. Environment.Exit(0);
  24. }
  25. else MakeEvenPalindrom();
  26. }
  27. public static void MakeEvenPalindrom()
  28. {
  29. int num;
  30. string one_part = null, two_part = null;
  31. while (true)
  32. {
  33. num = int.Parse(Numstr) + int.Parse(Invertstr);
  34. if (num.ToString().Length % 2 == 0)
  35. {
  36. for (var i = 0; i < num.ToString().Length / 2; i++)
  37. {
  38. one_part += num.ToString().Substring(i);
  39. for (var j = 0; j < Numstr.Length / 2; j++)
  40. two_part += num.ToString().Substring(num.ToString().Length - j, 1);
  41. }
  42. }
  43. else MakeOddPalindrom();
  44.  
  45. if (two_part == one_part)
  46. {
  47. Console.WriteLine("Число теперь палиндром", num);
  48. Environment.Exit(0);
  49. }
  50. else continue;
  51.  
  52. }
  53. }
  54.  
  55. public static void MakeOddPalindrom()
  56. {
  57. int num;
  58. string one_part = null, two_part = null;
  59. while (true)
  60. {
  61. num = int.Parse(Numstr) + int.Parse(Invertstr);
  62. for (var i = 0; i < num.ToString().Length; i++)
  63. one_part +=...
  64. }
  65. }
  66.  
  67. }
  68. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement