Advertisement
SkeptaProgrammer

Untitled

Oct 20th, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 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 ConsoleApplication3
  8. {
  9.     class Program
  10.     {
  11.         public static string Numstr, Invertstr = "";
  12.        
  13.         static void Main(string[] args)
  14.         {
  15.  
  16.         }
  17.  
  18.         public static void ReadAndCheck()
  19.         {
  20.            
  21.             Numstr = Console.ReadLine();
  22.             for (var i = 0; i < Numstr.Length - 1; i++)
  23.                 Invertstr += Numstr.Substring(Numstr.Length - i, 1);
  24.             if (Numstr == Invertstr)
  25.             {
  26.                 Console.WriteLine("Число является палиндромом");
  27.                 Environment.Exit(0);
  28.             }
  29.             else MakePalindrom();
  30.         }
  31.         public static void MakePalindrom()
  32.         {
  33.             int num;
  34.             while (true)
  35.             {
  36.                 string one_part = null, two_part = null;
  37.                 num = int.Parse(Numstr) + int.Parse(Invertstr);
  38.                 if (num.ToString().Length % 2 == 0)
  39.                 {
  40.                     for (var i = 0; i < num.ToString().Length/2; i++)
  41.                         one_part += num.ToString().Substring(i);
  42.                      
  43.                     for (var i = 0; i < num.ToString().Length / 2; i ++)
  44.                         two_part += num.ToString().Substring(i + 2);
  45.                     if (one_part == two_part)... // завтра продолжу отсюда
  46.                 }
  47.             }
  48.         }
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement