Advertisement
jackpieno

Reverse Integer 低智商爆力破解

Jun 22nd, 2021
855
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. public static class Reverse
  2.         {
  3.             public static int ReverseInt(int x)
  4.             {
  5.  
  6.                 int[] a = new int[10];
  7.                 int temp = x, b = 0, c = 1, d = 0, f = 0;
  8.                 bool n = false;
  9.                 if (x < 0)
  10.                 {
  11.                     x = x - x - x;
  12.  
  13.                     n = true;
  14.  
  15.                 }
  16.                 else if (x == int.MaxValue)
  17.                 {
  18.                     return 0;
  19.                 }
  20.                 while (x > 0)
  21.                 {
  22.                     a[b] = x % 10;
  23.                     b++;
  24.                     x = x / 10;
  25.  
  26.                     d++;
  27.  
  28.                 }
  29.                 d--;
  30.  
  31.                 while (true)
  32.                 {
  33.  
  34.                     if (d == -1)
  35.                         break;
  36.  
  37.                     f += a[d] * c;
  38.  
  39.                     c *= 10;
  40.  
  41.                     d--;
  42.  
  43.  
  44.                 }
  45.  
  46.                 if (n == true)
  47.                 {
  48.                     f = f - f - f;
  49.                     if (int.MinValue < f && f > 0)
  50.                     {
  51.                         return 0;
  52.                     }
  53.  
  54.                 }
  55.  
  56.                 d++;
  57.  
  58.                 if (f < temp && temp > 0 && a[d] != 0 && b == 10)
  59.                     return 0;
  60.  
  61.                 return f;
  62.  
  63.  
  64.  
  65.             }
  66.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement