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?

リアルタイムに解けた問題

A - Insert

問題文

長さ$N$の整数列$A$と整数$K$,$X$が与えられます。
整数列$A$の$K$要素目の直後に整数$X$を1つ挿入した整数列$B$を出力してください。

制約

  • 入力はすべて整数
  • $1 \leq K \leq N \leq 100$
  • $1 \leq A_{i},X \leq 100$

アルゴリズム

listのinsertメソッドを使用した。

ソースコード

N, K, X = map(int, input().split())

A = list(map(int, input().split()))

A.insert(K, X)

for a in A:
  print(a, end=' ')

print()
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?