Iamtui1010

num2str.fun

Sep 23rd, 2022 (edited)
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.25 KB | None | 0 0
  1. // goi thu vien algorithm cho ham reverse
  2. string num2str(int num)
  3. {
  4.     string str = "";
  5.     while (num > 0)
  6.         str += (num % 10 + '0'), num /= 10;
  7.     reverse(str.begin(), str.end());
  8.     if (!str.size())
  9.         str = 0;
  10.     return str;
  11. }
  12.  
Advertisement
Add Comment
Please, Sign In to add comment