К примеру так:
#include <iostream>using std::cout;using std::cin;using std::endl;
int main(){ int x; int x2; int counter = 0;
cout << "Enter x: "; cin >> x;
x2 = x;
while(x % 10) { x /= 10; counter++; }
x = 1;
for(int i = 0; i < counter - 1; i++) { x *= 10; }
x *= x2 / x;
x2 -= x;
cout << x2 << endl;
return 0;
}
К примеру так:
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
int main()
{
int x;
int x2;
int counter = 0;
cout << "Enter x: ";
cin >> x;
x2 = x;
while(x % 10)
{
x /= 10;
counter++;
}
x = 1;
for(int i = 0; i < counter - 1; i++)
{
x *= 10;
}
x *= x2 / x;
x2 -= x;
cout << x2 << endl;
return 0;
}