Submit | All submissions | Best solutions | Back to list |
PRF02LOOP03 - LOOP |
Write a program that displays the number-triangle with N lines and is formatted as below.
Example 1:
Please enter the positive integer N:0
N must be greater than 0!
Example 2:
Please enter the positive integer N:5
The number-triangle that has 5 lines is:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
Note by Editorial Board
This program outputs prompts as though it is running in an interactive environment. SPOJ isn't interactive, and you'll get a better idea of what the real output should look like if you run your program in a similar non-interactive environment, such as ideone. I've done this and added the output below to give an alternative view of how the output should be formatted. Note the lack of newlines after the prompts. It looks like the problem setter has chosen the exact judge, so your output must match exactly.
Example
Input: 0 Output: Please enter the positive integer N:N must be greater than 0!
Input: 5 Output: Please enter the positive integer N:The number-triangle that has 5 lines is: 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
Added by: | khanhvh |
Date: | 2020-10-26 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |