# Ka recursive programming exercises part2| the positive sequence output, arithmetic progression and

Source: Internet
Author: User

`1#include <stdio.h>2 voidPP (intN)3 {4     if(n==0)return;5PP (n/Ten);6printf"%d", n%Ten);7 }8 voidNP (intN)9 {Ten     if(n==0)return; Oneprintf"%d", n%Ten); APP (n/Ten); - } - intAd (intN) the { -     if(n==0)return 0; -     if(n==1)return 1; -     returnAd (n1)+N; + } - intMain () + { A     intN; atscanf"%d",&n); -printf"%d\n", Ad (n)); - PP (n); -printf"\ n"); - NP (n); -     return 0; in}`

PP is the positive sequence, NP is reverse order, ad is a series and.

The difference between PP and NP is that, as the deeper the n%10 is the higher, so pp first into the bottom, then output, NP first output, and then into the deep call.

Ad Note that +n is not +1, otherwise it will output the original number at the end. (Think about it, why?) ）

Ka recursive programming exercises part2| the positive sequence output, arithmetic progression and

Related Keywords:

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.