Advertisement
WadeRollins2710

Compare 2 big number [THCS4 N1]

Oct 26th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. //Tran Viet Anh - 9:43PM
  2. int compare(string x, string y)
  3. {
  4.     if (x.length() > y.length()) return 1;
  5.     else
  6.         if (x.length() < y.length()) return -1;
  7.         else
  8.         {
  9.             for (int i = 0; i < x.length(); i++)
  10.                 if (x[i] > y[i]) return 1;
  11.                 else if (x[i] < y[i]) return -1;
  12.             return 0;
  13.         }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement