Advertisement
jackpieno

IsPalindrome低智商爆力破解

Jun 22nd, 2021
1,284
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.73 KB | None | 0 0
  1. public static class IsPalindrome
  2.         {
  3.             public static bool IsPalindromeInt(int x)
  4.             {
  5.                 if (x < 0)
  6.                     return false;
  7.  
  8.  
  9.                 int[] a = new int[10];
  10.                 int temp = 0, b = 0;
  11.  
  12.                 while (x > 0)
  13.                 {
  14.                     a[b] = x % 10;
  15.                    
  16.                     x = x / 10;
  17.                     b++;
  18.                 }
  19.                 temp = b;
  20.                 b--;
  21.                 for (int i =0;i< temp;i++)
  22.                 {
  23.                     if (a[i] != a[b])
  24.                         return false;
  25.  
  26.                     b--;
  27.  
  28.                 }
  29.  
  30.  
  31.  
  32.                 return true ;
  33.             }
  34.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement