К примеру так:
#include
using std::cout;
using std::cin;
using std::endl;
int main()
{
int x;
int x2;
int counter = 0;
cout << "Enter x: ";<br> 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;</p>
return 0;
}