Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 KB | None | 0 0
  1. public class Program
  2.     {
  3.         static void Main(string[] args)
  4.         {
  5.             string final = null;
  6.                 for (int i = 100; i < 1000; i++)
  7.                 {
  8.                     for (int b = 100; b < 1000; b++)
  9.                     {
  10.                         int toCheck = i * b;
  11.                         string stringToCheck;
  12.                         stringToCheck = toCheck.ToString();
  13.                         if (stringToCheck.Equals(Reverse(stringToCheck)))
  14.                         {
  15.                             final = stringToCheck;
  16.                         }
  17.                     }
  18.                 }
  19.  
  20.                 Console.WriteLine(final);
  21.                 Console.ReadLine();
  22.         }
  23.  
  24.  
  25.         public static string Reverse(string s)
  26.         {
  27.             Stack<string> stack = new Stack<string>();
  28.  
  29.             for (int i = 0; i < s.Length; i++)
  30.                 stack.Push(s.Substring(i, 1));
  31.  
  32.             string ts = string.Empty;
  33.             for (int i = 0; i < s.Length; i++)
  34.                 ts += stack.Pop();
  35.  
  36.             return ts;
  37.         }
  38.  
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement