/*Copyright(c)2014,烟台大学计算机学院
*All rights reserved.
*文件名称:test.cpp
*作者:满星辰
*完成日期:2014年 11月 13日
*版本号:v1.0
*
*问题描述:分离正整数中的各位数
*程序输入:整数
*程序输出:正整数中的各位数
*/
#include <iostream>
using namespace std;
void f(int n);
int main()
{
int a;
while(cin>>a)
{
f(a);
cout<<endl;
}
return 0;
}
void f(int n)
{
if(n==0)
return;
else
{
cout<<n%10<<' ';
f(n/10);
return;
}
}
运行结果: