연쇄 창업을 위한 인간수업
반응형

백준 이용한 ruby 연습 2

 

1. 2739번

<python />
n = gets.chomp.to_i for i in 1..9 puts "#{n} * #{i} = #{n*i}" end

 

2. 2741번

<python />
n = gets.chomp.to_i for i in 1..n puts i end

 

3. 2439번

<python />
n = gets.chomp.to_i k = 1 while n >= 1 for j in 1..n-1 print " " end for y in 1..k print"*" end k = k+1 print "\n" n = n-1 end

 

4. 10818번

<python />
gets;a=gets.split.map &:to_i;puts"#{a.min} #{a.max}"

 

5. 1978번

<python />
n=gets.to_i a=gets.split.map &:to_i count=0 for i in 0...n if a[i] > 1 for j in 2..a[i] break if a[i]%j ==0 end count += 1 if j == a[i] end end puts count

 

 

 

 

 

 

 

반응형
profile

연쇄 창업을 위한 인간수업

@회뜨는참치

이 글이 당신에게 조금이라도 도움이 된다면 좋겠습니다.