Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n, a=0, b=0, va, m, ncif=1, i, z;
- cin >> n;
- m=n;
- while (m>9)
- {
- ++ncif; m/=10;
- }
- z=1;
- for (i=1; i<=ncif/2; ++i) z*=10;
- if (ncif%2==0) { a=n/z; b=n%z; }
- else { a=n/z; b=n%z; a=a/10; }
- va=a-b; if (va<0) va=-va;
- cout << va << "\n";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement