-
Notifications
You must be signed in to change notification settings - Fork 0
/
1146.php
27 lines (21 loc) · 881 Bytes
/
1146.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// beecrowd | 1146
// Growing Sequences
// Adapted by Neilor Tonin, URI Brazil
// Timelimit: 2
// Your program must read an integer X indefinited times (the program must stop when X is equal to zero). For each X print the sequence from 1 to X, with one space between each one of these numbers.
// PS: Be carefull. Don't leave any space after the last number of each line, otherwise you'll get Presentation Error.
// Input
// The input file contains many integer numbers. The last one is zero.
// Output
// For each number N of the input file, one output line must be printed, from 1 to N like the following example. Be careful with blank spaces after the last line number.
while(true){
$input = intval(fgets(STDIN));
if($input == 0){
break;
}
for($x = 1; $x <= $input; $x++){
echo ($x == $input) ? $x : $x . " ";
}
echo "\n";
}