0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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

Last updated at Posted at 2024-01-17

Python

N = int(input())
A = [int(i) for i in input().split()]
for i in A:
    print(i * 2)

PHP

for文で、要素数−1しているのは
0から数えるので、
0,1,2,3,4で要素5個だけど、−1して4までにする必要があるからですね
Pythonと違うので注意したいところです
まあこの部分は$N-1 でもよいのですが

<?php
    $N = trim(fgets(STDIN));
    $A = explode(" ",fgets(STDIN));
    for ($i=0; $i<=count($A)-1; $i++){
        print($A[$i]*2 . "\n");
    }
?>

Python

N = int(input())
A = [int(i) for i in input().split()]
B = list(map(int,input().split()))
for i in range(N):
    print(A[i]-B[i])

PHP

<?php
    $N = trim(fgets(STDIN));
    $A = explode(" ",fgets(STDIN));
    $B = explode(" ",fgets(STDIN));
    for ($i=0; $i<=$N-1; $i++){
        print($A[$i]-$B[$i] . "\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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?