How write a recursive print program

前端 未结 8 2059
没有蜡笔的小新
没有蜡笔的小新 2021-01-29 16:02

Gurus,

I want to know how to write a recursive function that prints

1
12
123
1234
...
......

For eg: display(4) should print

8条回答
  •  失恋的感觉
    2021-01-29 16:42

    #include
    void print_num(int x);
    int n;
    void main(){
    printf("Enter number of lines: ");
    scanf("%d",&n);
    print_num(1);
    }
    void print_num(int x){
    int i;
    for(i=1;i<=x;i++){
    printf("%d",i);
     }
    if(x

    This is simple, right?

提交回复
热议问题