Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string number_to_string(int x) {
- string s = "";
- while(x > 0) {
- s += (x % 10) + '0';
- x /= 10;
- }
- reverse(s.begin(), s.end());
- return s;
- }
- int string_to_number(string &s) {
- int number = 0;
- for(int i = 0; i < s.size(); i++) {
- number = (number * 10) + (s[i] - '0');
- }
- return number;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement