P0014. Numerical valleys P80868


Statement
 

pdf   zip

thehtml

Your task is to write a program that, given two natural numbers n and r, uses n to print a valley with r rows as it is shown at the instances. Notice that, the last row has r numbers n separated by dashes, the central dot, and r numbers n separated by dashes, that each row has two numbers n 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

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

Input

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

Output

Your program must print a valley of r rows using the number n 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++