読み込んだ整数値を0までカウントダウン (while文)

明解C言語 入門編 > 4. プログラムの流れの繰り返し >

読み込んだ整数値を0までカウントダウン (while文)

Perl
print "正の整数を入力してください:";
chomp($no = <>);
while ($no >= 0)
{
    printf("%d\n", $no--);
}

print "正の整数を入力してください:";
chomp($no = <>);
printf("%d\n", $no--) while ($no >= 0);

print "正の整数を入力してください:";
chomp($no = <>);
until ($no < 0)
{
    printf("%d\n", $no--);
}

print "正の整数を入力してください:";
chomp($no = <>);
printf("%d\n", $no--) until ($no < 0);

実行結果

L:\>perl lesson_04_027.pl
正の整数を入力してください:7
7
6
5
4
3
2
1
0
正の整数を入力してください:6
6
5
4
3
2
1
0
正の整数を入力してください:5
5
4
3
2
1
0
正の整数を入力してください:4
4
3
2
1
0