P0014. Numerical valleys P80868


Statement
 

pdf   zip

Your task is to write a program that, given two natural numbers nn and rr, uses nn to print a valley with rr rows as it is shown at the instances. Notice that, the last row has rr numbers nn separated by dashes, the central dot, and rr numbers nn separated by dashes, that each row has two numbers nn less than the row immediataly below, and that the part of the middle has to be filled with as many dots as necessary.

To solve this problem, you must implement recursively the function

    int number_of_digits(int n);

that returns the number of digits of |n|, under the precondition |n| 0\ge 0.

Input

The input consists of two natural numbers nn and rr, with r>0r > 0.

Output

Your program must print a valley of rr rows using the number nn as can be seen in the instances.

Observations

  • Using strings is not allowed. Obviously, you can not use vectors either.

  • Remember to implement |number_of_digits(n)| recursively.

Public test cases
  • Input

    10004
    3
    

    Output

    10004.........................10004
    10004-10004.............10004-10004
    10004-10004-10004.10004-10004-10004
    
  • Input

    0
    6
    

    Output

    0.....................0
    0-0.................0-0
    0-0-0.............0-0-0
    0-0-0-0.........0-0-0-0
    0-0-0-0-0.....0-0-0-0-0
    0-0-0-0-0-0.0-0-0-0-0-0
    
  • Input

    987654321
    1
    

    Output

    987654321.987654321
    
  • Information
    Author
    Professorat de P1
    Language
    English
    Translator
    Carlos Molina
    Original language
    Catalan
    Other languages
    Catalan
    Official solutions
    C++
    User solutions
    C++