Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cmath>
- using namespace std;
- char *stroka (int znach)
- {
- int n = 1;
- int c = 0;
- while (znach/n != 0)
- {
- n *= 10;
- c++;
- }
- n /= 10;
- char *result = new char[c+1];
- if (znach < 0)
- {
- znach = abs(znach);
- result[0] = '-';
- for (int i = 1; i <= c; i++)
- {
- result[i] = (znach/n) + 48;
- znach %= n;
- n /= 10;
- }
- }
- else
- for (int i = 0; i < c; i++)
- {
- result[i] = (znach/n) + 48;
- znach %= n;
- n /= 10;
- }
- return result;
- }
- int main()
- {
- string s;
- int znach;
- cin >> znach;
- s = stroka(znach);
- cout << s;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement