Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<string>
- using namespace std;
- int mass[11];
- int main() {
- string n;
- cin >> n;
- int ans = 0, z = 0, x = 1;
- for (int i = 0; i < n.size(); i++) {
- if (n[i] == '-') z = 1;
- else
- mass[i] = n[i] - '0';
- }
- if (z == 1) {
- for(int i = n.size() - 1; i > 0; i --) {
- ans += mass[i] * x;
- x = x * 10;
- }
- ans = ans * (-1);
- } else
- for(int i = n.size() - 1; i >= 0 ; i --) {
- ans += mass[i] * x;
- x = x * 10;
- };
- cout << ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement