精彩百例:函数的递归调用
来源:互联网 发布:怎样开淘宝网店需要多少钱 编辑:程序博客网 时间:2024/04/30 15:03
/* filename: the recursion function: convert the number to char*/# include <stdio.h>void convert_num(int num);int main(void){ int num; printf("Please input the number what you need convert: "); scanf("%d", &num); printf("\nThe number is %d.\n", num); /*if the number is negative ,add minus front of the number*/ if(num < 0) { putchar('-'); num = -num; } /*convert the number to char*/ printf("convertting the number .....\n"); convert_num(num); return 0;}/*convert the number to char*/void convert_num(int num){ int i; if((i=num/10) != 0) convert_num(i); putchar((num%10)+'0');}/* 递归: 当条件成立,进入第二层调用,当下一次条件成立,进入第三层调用 当条件不再成立,执行判断之后的语句,执行完之后,跳出最深层的函数(这里指第三层), 进入次一级的函数(这里指第二层), 一直这样循环,直到跳出所有的函数*/
result:
0 0
- 精彩百例:函数的递归调用
- 精彩百例:数组函数调用
- 函数的递归调用
- 函数的递归调用
- 函数的递归调用
- 函数的递归调用
- 函数的递归调用
- 函数的递归调用
- 函数的递归调用
- 函数的递归调用
- 精彩百例:exit()函数
- 精彩百例:函数指针
- 9.8 函数的递归调用
- 函数的递归和调用
- 递归函数调用的代价
- C++函数的递归调用
- 030 函数的递归调用
- 4.10、函数的递归调用
- Ubuntu14.04下安装eclipse
- Leetcode解题-链表(2.2.3)PartitionList
- 读书笔记---windows startup and shutdown
- 第四周程序阅读(2)
- 杭电1228 A+B
- 精彩百例:函数的递归调用
- 五大算法之二--动态规划
- ResultSet用法集锦
- Unity编辑器扩展之RequireComponent等详解
- HDOJ 1240 Asteroids! 【BFS+优先队列】
- 在.NET Framework 2.0即以下平台下操作UDT
- 五大算法之三--贪心算法
- quartus中引脚配置
- POJ_2481(树状数组)