Home > Back-end >  Always look not to understand function tutorial
Always look not to understand function tutorial

Time:09-27

Dear bosses, can provide some function tutorial information

CodePudding user response:

Frankly, this syntax is simple, the simple function hasn't arrived yet complicated place, is to encapsulate some process, you give input, and then he gives you the output, shielding the details,

CodePudding user response:

Practice more, you can understand, is difficult to understand pointer argument,

CodePudding user response:

Is:
You are int main () call this function when the int main () have to do as your function

CodePudding user response:

If it is a recursive · · · · · ·
What is a recursive function

(1) a recursive function that is from the function, inside the function directly or indirectly, that calls itself the function is the function of nested call itself,

Literally look at recursion, pass the recursion, the thinking of loop is used to describe the complex problem, in the recursive phase each recursive call by further call themselves to remember the recursive process, when the calls to meet the termination conditions, recursive end, namely regression, regression function call has reverse way, know the function returns that call in the first place, the end of the recursive process,

(2) the basic principle of recursive

First: each level of the function call has its own variables,

Second: once every function call returns,

Third: recursive functions, is located in the recursive call in front of the statement and all levels of the called function with the same sequence of execution,

Fourth: recursive functions, is located in the recursive call after the execution of the statement of order and the order of the called function, on the other hand,

Fifth: although each level has its own recursive variable, but the function code will not be copied,

Finally: recursive function must contain the recursive call can be terminated by the statement,

(3) the advantages and disadvantages of recursive

Its advantage is that provides some become problem with the simplest solution, simplifies the design program, while the disadvantage is that some recursive algorithm will soon run out of the computer's memory resources, at the same time, using recursive procedure is difficult to read and maintain,

Two, mechanism of function calls that

Cannot be nested between any function definition, the function and the called function are independent of each other between the concept of recursive function usage with instance (can call each other), when the function call, the called function in the protection of the running environment of the calling function and the return address, causing the called function state can run the called function returns fully recovered, and the state has nothing to do with the called function,

The called function while running the code is the code for the same function body, but as a result of calls, call state, return point is different, can be regarded as a function of one copy, has nothing to do with the function code, so the function of the code is independent, the called function of stack space is independent of the function call stack space, so has nothing to do with the data between the calling function is, function, test parameters and return values to a link between the function as a black box,

This mechanism determines the C/C + + allows function recursive calls,

CodePudding user response:

Simple function function is what others do, you bring them here directly with
Wrote a function by yourself, you want to string those features of function can be implemented,
You know how to write a few more calls,
For example,
Int found_arry (int * p, int n)//this is a search function, you need to pass a pointer to the function, or an array name, and to a search, and it will return to you an integer represents find 0 found, for example - 1
Where is wrong please also criticized

CodePudding user response:

You didn't understand your needs,
What is your understanding of the function? You need to answer, explanation,
Suppose I don't know more than you function, you can explain to me, what would you say,
~ ~ ~ ~ ~
Next is the problem, you don't understand about what function?
What bothering you?
~ ~ ~ ~ ~ ~ ~
Not one of the teaching material is a panacea, can satisfy all readers of
At the very least, you should be a function of teaching materials,
~ ~ ~ ~ ~ ~ ~
In actual use, use the function to do some things,
Experience, what function?
You should understand that a layer? Don't be too greedy to want to know too many details, you should get a grip on yourself to understand to which layer,
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~

CodePudding user response:

Int type ABC////function function name (int a//into a number)//for the absolute value of a
{
If (a & gt; 0) return a;
The else return - a;
//function body: what function do
}
Int main ()
{
int a;
cin> a;
coutreturn 0;
}
  • Related