`
yunchow
  • 浏览: 317717 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

c++ 递归实例二

    博客分类:
  • C++
阅读更多
#include <iostream.h>
//using namespace std;

void show(unsigned int n);

int main(void)
{
	for(;;)
	{
		int t;
		cout << "Please enter an num : " ;
		cin >> t;
		if(t < 0)	break;
		else 
		{
			cout << "The result is : ";
			show(t);
		}//end else
		cout << endl;
	}//end for(;;)
	cout << "\nThank you for testing...Bye!!!\n" << endl;
}//end main

void show(unsigned int n)
{
	if(n>=10)
	{
		show(n/10);
		cout << ' ';
	}//end if
	cout << n%10;
}//end function show(unsigned int n)
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics