標籤:style http java color os 2014
Some Classical Recursive FunctionsSome Classical Recursive FunctionsTable of Contents
- 1. Find the maximum element of an array recursively.
In this post, I will list the commonly met recursive functions that can lightthe road for further investigation into the magic world of computer science.
I am not an excellent programmer myself, but through delight practice, thelittle but essential part of the RECURSIVE PROBLEMS can be understood. So I willpresent some examples to illustrate what I mean.
1 Find the maximum element of an array recursively.
#define max(a,b) (a) > (b) ? (a) : (b)int f_max(int *a,int start,int end){ if (start == end) { return a[start]; } return max(a[start],f_max(a,start + 1,end));}void test_max(void){ int a[] = { 12,1,22,56,4 }; printf("max=%d\n",f_max(a,0,4));}
Author: wujing
Created: 2014-07-13 日 10:45
Emacs 24.3.1 (Org mode 8.2.6)
Validate