0
0

ループメニュー1を解いていく4

Posted at

Python

N = int(input())
A = list(map(int,input().split()))
# reversed関数を使うなら
print((*reversed(A)),sep="\n")
# for文を使うなら
for i in range(N-1,-1,-1):
    print(A[i])

PHP

$Aはtrimしないと後ろに改行がくっついたままexplodeしてしまうので注意。

<?php
    $N = trim(fgets(STDIN));
    $A = explode(" ",trim(fgets(STDIN)));
    for($i=$N-1; $i>=0; $i--){
        print($A[$i] . "\n");
    }
    //reverse関数を使うならこれでも。でもぶっちゃけ上の方が早い
    $A = array_reverse($A);
    for($i=0; $i<=$N; $i++){
         print($A[$i] . "\n");
    }
    
?>

Python

for i in range(1,10):
    if i < 9:
      print(i * 8, end=" ")
    else:
        print(i * 8)

PHP

<?php
    for($i=1; $i<=9; $i++){
        if($i < 9){
            print($i * 8 . " ");
        } else {
            print($i * 8 . "\n");
        }
    }
?>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0