First, the experimental work 1.1 PTA topic 6-3 Recursive calculation p function Design thinking
在函数P内定义一个双精度浮点型变量y用来储存运算结果如果(n==0) return 1如果(n==1) return x如果(n>1) y=1.0*((2*n-1)*P(n-1,x)-(n-1)*P(n-2,x))/n return y
Code
Debugging issues
The main problem encountered in this topic is that the variable type is not clear, resulting in incorrect calculation results, through debugging solution.
1.2 Student performance Management System 1.2.1 Drawing function module diagram, Brief introduction function function 1.2.2 Show project file 1.2.3 function code part of this system code total number of lines: 1.2.4 Debug results show two, this week topic set PTA Final Ranking
Third, read the code
Any element of M (m≤n) from n different elements, arranged in a certain order, is called an arrangement of extracting m elements from n different elements. All permutations are called when m=n.
The full arrangement of three elements such as the three-in-one is:
The
1,3,2
2,1,3
2,3,1
3,1,2
3,2,1
Code:
inline void Swap(int &a,int &b){ int temp=a; a=b; b=temp;}void Perm(int list[],int k,int m){ if (k == m-1) { for(int i=0;i<m;i++) { printf("%d",list[i]); } printf("n"); } else { for(int i=k;i<m;i++) { Swap(list[k],list[i]); Perm(list,k+1,m); Swap(list[k],list[i]); } }}
This code uses two functions to recursively output the full array, and this method of using multiple functions recursively is worth learning.
Iv. Summary of the study this Week 1. Introduce this week's learning content
This week, we learned the application of recursive functions and recursion, in short, recursion is the process of writing a special procedure in which a statement is used to invoke the process itself. Recursive process because of the implementation of self-nested execution, so that the implementation of the process becomes complex, you can use recursive algorithm to solve a lot of complex problems.
Also learned about function nesting, the function's nested call is to call other functions in the function call, the function's recursive call is to call the function itself in the function call.
It is also possible to solve many complex problems by nesting calls to functions.
2. Learning Experience
Although this week to learn the knowledge can understand, but the actual application and mastery is not too clear, so also to learn more, more practice, this part of the content fully mastered.
C Language Blog Job--function nested call