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?

More than 3 years have passed since last update.

Ruby足し算

Last updated at Posted at 2020-11-02

#ruby足し算
#入力される値

  • a
  • b

#期待する出力

  • aとbを足した数を出力

#入力例

  • 1 1  (1と1です)

#出力例

  • 2
パターン1
a = gets.to_i
b = gets.to_i
puts a + b
パターン2
a = gets.to_i
b = gets.to_i
num = a + b
puts num
パターン3
a = gets
b = gets
puts a + b
パターン4
a = gets
b = gets
puts (a + b).to_i
パターン5
a = gets.to_s
b = gets.to_s
puts a + b

パターンといえるほど大した事はしてないが、なんせただの「1+1」ができない。おそらくpai○a独特なルールで縛りを受けてるからテストが通らないんですね〜、、本日はここに4時間ほど時間をかけて収穫は0でした。無念

#追記

これでできました
s = gets.split(' ').map(&:to_i)
result = s[0] + s[1]
puts result

#以上

0
0
1

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?