recursive invocation of functions

Source: Internet
Author: User

Serial 1

First came to infinite interconnection, although there are a lot of things do not understand, but with the teacher patient introduction and careful care, he quickly adapted to the environment here, really thank the unlimited connected teachers.

This week is our first week of training, with a lot of classmates in the Tang Dynasty accompany, boring training life is not so boring, see the class more than the students from Anhui, Hunan, suddenly feel that the original North drift of their own is not so hard, than our efforts, than we have the courage, more than our hard prospective graduates.

the first week of training self-feeling is good, because at school time C Language Foundation is also good, very relaxed can keep up with the teacher's progress, hope later can also study very good.

The most impressive thing about this week is the use of recursive functions, with two recursive invocation examples to help you understand:

#include <stdio.h>

void recursive (int a)

{

// If a condition that does not jump out of the loop calls causes a dead loop call

if (a = = 0)

{

// jump out of loop call

return;

}

printf ("%d\n", a);

A--;

// recursive invocation

Recursive (a);

}

// factorial recursive invocation

int factorial (int a)

{

if (a = = 1)

{

return1;

}

return A * factorial (A- 1);

}

int Main (int argc, charconst *argv[])

{ //1. Decrement Output 3 2 1   

    // Recursive invocation

recursive (ten);

//2 to find factorial 5*4*3*2*1

int res = factorial (5);

printf ("5*4*3*2*1=%d\n", res);

return 0 ;

}




650) this.width=650; "Src=" http://b282.photo.store.qq.com/psb?/V10rOjke2fsbep/ L2nuffg9fhsu1odunuen68ykppo23dnelglgjcpn3v4!/c/dbobaaaaaaaa&bo=halaawaaaaafap4!&rf=mood_app "Width=" 128 "Style=" border:0px;vertical-align:top;margin-top:-49.5px; "alt=" dbobaaaaaaaa&bo=halaawaaaaafap4!&rf= Mood "/>650) this.width=650;" Src= "http://b282.photo.store.qq.com/psb?/V10rOjke2fsbep/ 5ahmgd5m6sf08wi61wda0iuqrnpasn3cmpt3n0htj8m!/c/dbobaaaaaaaa&bo=halaawaaaaafap4!&rf=mood_app "Width=" 128 "Style=" border:0px;vertical-align:top;margin-top:-49.5px; "alt=" dbobaaaaaaaa&bo=halaawaaaaafap4!&rf= Mood "/>650" this.width=650; "src=" Http://b282.photo.store.qq.com/psb?/V10rOjke2fsbep/G. Bdvg0x5o.gwpva3jdvxmpzmwxhmrt4byswfgtnj60!/c/dbobaaaaaaaa&bo=tac0aaaaaaafacm!&rf=mood_app "height=" 128 " Style= "border:0px;vertical-align:top;" alt= "Dbobaaaaaaaa&bo=tac0aaaaaaafacm!&rf=mood"/>650) this.width=650; "Src=" Http://b283.photo.store.qq.com/psb?/V10rOjke2fsbep/NaQwKp6rwIKcATmfr8417r2llwxdnre*0wxoiodjqdq!/c/dbsbaaaaaaaa&bo=bqjmagaaaaafacg!&rf=mood_app "height=" "style=" border:0px;vertical-align:top;margin-left:-1px; "alt=" Dbsbaaaaaaaa&bo=bqjmagaaaaafacg!&rf=mood "/>650 ) this.width=650; "Src=" http://b84.photo.store.qq.com/psb?/v10rojke2fsbep/.9fegymvbilnrxfgcnqj*1g4* 3kkkxxehu99yj.ajhs!/c/dfqaaaaaaaaa&bo=wahtaqaaaaafakg!&rf=mood_app "width=" "style=" border:0px; vertical-align:top;margin-top:-23px; "alt=" Dfqaaaaaaaaa&bo=wahtaqaaaaafakg!&rf=mood "/>








recursive invocation of functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.