2
1

More than 1 year has passed since last update.

プログラム課題(paizaの森)

Posted at

paiza様のpaizaの森のプログラム課題からこんな問題を解きました。

1行目に入力する数を決める
2行目以降に2つの数を入力し、2つの数が同じなら2つの数を掛け、2つの数が異なるなら2つの数>を足す。これを1行目に入力するデータの数だけ行い、計算結果を表示する。

プログラムで書きました

# coding: utf-8
# 自分の得意な言語で
# Let's チャレンジ!!
num = int(input())
sum1 = 0
for i in range(num):
    ans1 = 0
    data = input()
    array1 = data.split(' ')
    A = int(array1[0])
    B = int(array1[1])
    if A == B:
        ans1 = A * B
    else:
        ans1 = A + B
    sum1 += ans1
print(sum1)
2
1
2

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
2
1