Advertisement
allia

перевод в число

Sep 18th, 2020 (edited)
1,148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.34 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.   string znach;
  8.   cin >> znach;
  9.  
  10.   int n = znach.size();
  11.  
  12.   if (znach[0] == '-')
  13.    {
  14.      cout << znach[0];
  15.     for (int i = 1; i < n; i++)
  16.        cout << znach[i] - 48;
  17.    }
  18.    else for (int i = 0; i < n; i++)
  19.        cout << znach[i] - 48;
  20.  }
  21.  
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement