C Language Blog Job--function nested call

Source: Internet
Author: User

---restore content starts---

First, the experimental work student performance management System Requirements 1.1 PTA topic 6-5 Recursive implementation sequential output integer
    • Design ideas

      输入数字n调用函数 printdigits(n){定义变量res表示顺次输出的数字IF n/10=0res←n    递归出口否则调用函数printdigits(n-1)res←n%10输出res
    • Code

    • Debugging issues

      When the judgment condition is n=0, the result of entering a single number is wrong, instead n/10=0 can be

Second, this week's topic set PTA Final Ranking

Third, read the code to a certain number of steps there are several ways
#include <stdio.h>#include <stdlib.h>#include <string.h>static int step[128];static int m = 1;int count(unsigned int n);void cout(int n,int t);int main(){int a;    unsigned int n;    while(1){printf("请输入需要登上的台阶数量:");scanf("%d",&n);a = count(n);printf("登上%d个台阶共有%d种方法!分别如下:\n",n,a);cout(n,0);                m=1;    }system("pause");return 0;}int count(unsigned int n){    if(n == 1)        return 1 ;    if(n == 2)        return 2 ;    else         return count(n - 1) + count(n - 2) ;}void cout(int n,int t){    int i,j;    if(n<0)    return ;if(n == 0)    {printf("第%d种方法:",m);for(j=0;j<t;j++)            printf("%d ",step[j]);m++; printf("\n");    }    else    {for(i=1;i<=2;i++){step[t] = i;cout(n-i,t+1);}    }}
The function outputs the sum of all the sums of a number and sorts the digits of the number, and sets the static global variables before recursion to realize the condition that the recursive time-varying quantity does not reset. Iv. Summary of this week's study
    • learned about recursive functions and macros with parameters
    • You can set the number of pointers to hold pointer variables and set function pointers so that pointers point to functions
    • Defines a pointer to a pointer to a level two pointer
    • You can use the malloc () function to set up dynamic memory to avoid wasted space, freeing memory with the free () function
Learning experience
    • There is still some misunderstanding about the engineering documents, not very understanding.

C Language Blog Job--function nested call

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.