0
0

配列のソート/反転/要素数のカウント/配列末尾への追加 Python3編

Last updated at Posted at 2023-12-10

こないだコメントで教えていただいたのが早速(出力で)役に立った!
まったく便利だなぁ
答えを見たけど、下記を簡単に書いたものだったので省略

N = int(input())
A = list(map(int,input().split()))
print(*sorted(A), sep="\n")

簡単すぎたので次の問題も

N = int(input())
A = list(map(int,input().split()))
print(*reversed(A), sep="\n")

やっぱり簡単だったので次の問題も

N, M = map(int,input().split())
A = list(map(int,input().split()))
print(A.count(M))

次の問題。。。

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.append(M)
print(*A,sep="\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