vstoyanov

Untitled

Jan 4th, 2018
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 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 ConsoleApp1
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int firstNum = int.Parse(Console.ReadLine());
  14.             int secondNum = int.Parse(Console.ReadLine());
  15.  
  16.             int firstDelimeter = 10;
  17.             int secondDelimeter = 10;
  18.  
  19.             int count = 0;
  20.  
  21.             int multyply = 10;
  22.  
  23.             int a = 0;
  24.             while (true)
  25.             {
  26.                 int lastDigitFirst = (firstNum % firstDelimeter);
  27.                 int lastDigitSecond = (secondNum % secondDelimeter);
  28.  
  29.                 if (a > 0)
  30.                 {
  31.                     lastDigitSecond = (secondNum % secondDelimeter) / multyply;
  32.                     multyply = multyply * 10;
  33.                 }
  34.                 if (lastDigitSecond == lastDigitFirst)
  35.                 {
  36.  
  37.                     firstNum = firstNum / 10;
  38.  
  39.                     multyply = 10;
  40.                     secondDelimeter = 10;
  41.                     a = -1;
  42.  
  43.                 }
  44.                 else
  45.                 {
  46.  
  47.                     secondDelimeter = secondDelimeter * 10;
  48.                    
  49.                 }
  50.  
  51.  
  52.                 if (firstNum == 0)
  53.                 {
  54.                     count++;
  55.                     break;
  56.                 }
  57.  
  58.                 if (multyply > 1000000000)
  59.                 {
  60.                     break;
  61.                 }
  62.                 a++;
  63.                
  64.             }
  65.  
  66.             if (count == 1)
  67.             {
  68.                 Console.WriteLine("Yes");
  69.             }else
  70.             {
  71.                 Console.WriteLine("No");
  72.             }
  73.  
  74.  
  75.  
  76.         }
  77.     }
  78. }
Add Comment
Please, Sign In to add comment