#include <bits/stdc++.h>
using namespace std;
int f(int x)
{
int n;
if(x>0)
{
if(x%2==0)
{
cout<<x%10;
n=1+f(x/10);
}
else
{
n=1+f(x/10);
cout<<x%10;
}
return n;
}
else
return 0;
}
int main()
{
cout<<' '<<f(8174);
return 0;
}
So on my computer it displays " 48174" but on my friend's computer it displays "4817 4". The correct answer in the book is "4817 4". I don't understand why would the space be between numbers because I call cout<<' '; before I call the function. Can you help me understand which is the right way?