1
0
Fork 0
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
485 B
C

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

//recursive algorithm
void PrintDigit(int n)
//PrintDigit()函数实现将单个数字(0-9)输出
{
if (n < 0 || n > 9)
{
cout << "只输出单个数字(0-9)!" << endl;
exit(0);
}
cout << n << " ";
}
void PrintOut(unsigned int n)
// PrintOut()将正整数n输出要求用递归函数实现
{
//在此插入你完成第一个任务的代码。要求1调用PrintDigit(int n)函数逐位输出2PrintOut(unsigned int n )函数是递归函数
if (n >= 10) PrintOut(n / 10);
PrintDigit(n % 10);
}