Advertisement
Josif_tepe

Untitled

Sep 11th, 2021
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. string number_to_string(int x) {
  2.     string s = "";
  3.     while(x > 0) {
  4.         s += (x % 10) + '0';
  5.         x /= 10;
  6.     }
  7.     reverse(s.begin(), s.end());
  8.     return s;
  9. }
  10.  
  11. int string_to_number(string &s) {
  12.     int number = 0;
  13.     for(int i = 0; i < s.size(); i++) {
  14.         number = (number * 10) + (s[i] - '0');
  15.     }
  16.     return number;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement