版权声明:本文为@那年聪聪 原创文章,未经博主允许不得转载。 https://blog.csdn.net/duan19920101/article/details/55511268
输入一个整数,输出:使用空格输出整数各个位的数
1.处理左边n-1位
2.输出空格
3.输出个位
1.处理左边n-1位
2.输出空格
3.输出个位
void show(int n)
{
if (n / 10 == 0)
cout << n << " ";
else
{
show(n / 10);
cout << n % 10 << " ";
}
}
int main()
{
int n;
cout << "请输入一个整数:";
cin >> n;
show(n);
cout << endl;
return 0;
}