Today, I finally talked about the scope of the C language. "Function" said that everything in the C language is really true (maybe, I don't know). Many books have said that the function is the C language, that is, the function is constituted in C language. Look at the following procedure:
Main ()
{
Printf ("Hello World");
}
Main () is the most special function in the C language, which is the key to constitute the entire program. In the C compiler, you first have to find out that this master is starting to perform compilation, well, said some books. Now let's take a look at how the function in the C language is. If we don't mean from the foundation. Then we start from another feature of the function, "Recurrent Function" believes that many people know this, I have seen the tutorial of the old pool should all know the first recursive procedure of his classic:
INT ABC (INT N)
{
Int S;
IF (n> 1) s = N * ABC (N-1);
Else S = 1;
Return (s);
}
It is easy to see a function with your own name from this source. Therefore, in the future we have seen it in a function, it is a recursive function. And we look at a recursive function, it is mainly to see if it is a return condition, just like a dark and deep cave. We must go back before you go to the end, even more deeper must return! So we determine if a recursive function is established and often seeing its return condition. As for the source program above, I don't want to say more, I should understand it.
Here, look at another topic that uses the recursive function, it is the Noko Tower (there is also a book in the old man).
#include
Void Move (char X, char y)
{
Printf ("% C ->% C / N", X, Y);
}
Void Hanoi (int N, char one, char two, char three) {if (n == 1) Move (One, three); else {hanoi (N-1, One, Three, Two); Move (One, Three ); Hanoi (N-1, Two, One, Three);}}
Main () {Int m; Printf ("INPUT The Number of Diskes:"); Scanf ("% D", & M); Printf ("THE Step to Moving% 3D Diskees: / N", M); Hanoi (M , 'A', 'b', 'c');} / * Operations are as follows: Input the number of diskees: 3 Enter The Step to Moving 3 Diskes: a -> C A -> B C - > B A -> C B -> a b -> C A -> C
On the book, Hanoi (N-1, One, Three, TWO) is the "one" on "One" to "TWO", then move (one, three); then Hanoi (N-1, TWO, One, Three) Move N-1 on "TWO" to "Three"; | h (2, 1, 3, 2) | h (1, 1, 2, 3) => Move 1, 3) <----- 1 ------ | | Move (1,2) <----- 2 ------ | | h (1, 3, 1, 2) => Move (3, 2) <----- 3 ------ | Move (1, 3) <----- 4 ------ | H (3, 1, 2, 3) | H (1, 2, 3, 1) => Move (2, 1) <----- 5 ------ | H (2, 2, 1, 3) | Move (2 , 3) <----- 6 ------- | | h (1, 1, 2, 3) => Move (1, 3) <----- 7 ------ | * / Note that the above is written by a netizen online, not what I wrote. The most different from Norhan Tower is that it has repeatedly called themselves, so it looks more complicated. At that time, I was watching this program and I didn't understand the old half-day. It is best to see a friend on the Internet saying that he really took some dishes. I tried it. Later, I also I tried to see, the effect is really good (I certainly don't have a stupid drink, write big, middle, small) with my disc, you don't know how to visit. In addition, I saw this picture. I am also more clear, I want to thank the netizen, do you say it? This program must be slowly understood, I wish you all an early understanding. Recurrent function I can't say anything because I don't know much, now come to see another content of the function, is the parameter call of the function. I will give a program first: int ABC (int A, int b) {a = a = b; return (a b);} main () {int XY [] = {3,5}; int S; s = ABC (XY [0], XY [1]);} In the shape of XY [0] and XY [1], the point to say is different from other advanced languages, The function call of the C language is unidirectional. Limited to participate in the ginseng, it will not return to the collections, so we must remember this. As another question: int A []) {INT I, J; / * Sort * /} main () {INT X [5] = {3, 5, 1, 2, 4} ABC (X ); / * Output * /} Why can this source change the value of the argument? The book is very clear in the book, saying because this is the address delivery, but our teacher does not agree with this. He said that this should also be transmitted, but this value is a relatively special value, the address, Therefore, it is possible to pass the elements that call this address by calling the shape. If this procedure is called the address, according to the old pool. INT ABC (INT * P) {* p = 10;