Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApplication3
- {
- class Program
- {
- public static string Numstr, Invertstr = "";
- static void Main(string[] args)
- {
- }
- public static void ReadAndCheck()
- {
- Numstr = Console.ReadLine();
- for (var i = 0; i < Numstr.Length - 1; i++)
- Invertstr += Numstr.Substring(Numstr.Length - i, 1);
- if (Numstr == Invertstr)
- {
- Console.WriteLine("Число является палиндромом");
- Environment.Exit(0);
- }
- else MakeEvenPalindrom();
- }
- public static void MakeEvenPalindrom()
- {
- int num;
- string one_part = null, two_part = null;
- while (true)
- {
- num = int.Parse(Numstr) + int.Parse(Invertstr);
- if (num.ToString().Length % 2 == 0)
- {
- for (var i = 0; i < num.ToString().Length / 2; i++)
- {
- one_part += num.ToString().Substring(i);
- for (var j = 0; j < Numstr.Length / 2; j++)
- two_part += num.ToString().Substring(num.ToString().Length - j, 1);
- }
- }
- else MakeOddPalindrom();
- if (two_part == one_part)
- {
- Console.WriteLine("Число теперь палиндром", num);
- Environment.Exit(0);
- }
- else continue;
- }
- }
- public static void MakeOddPalindrom()
- {
- int num;
- string one_part = null, two_part = null;
- while (true)
- {
- num = int.Parse(Numstr) + int.Parse(Invertstr);
- for (var i = 0; i < num.ToString().Length; i++)
- one_part +=...
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement