반응형
백준 이용한 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
반응형
'Develop > Backend' 카테고리의 다른 글
객체지향 : 상속성, 은닉성, 다형성 이란? (0) | 2023.05.01 |
---|---|
크로아티아 알파벳(백준 2941번) (0) | 2022.07.01 |
백준 - ruby 연습(10718번, 1000번, 1330번, 2753번) (0) | 2021.12.15 |
[JSP] 로그인 페이지 구현 (0) | 2020.11.05 |
While 문이란? (0) | 2019.11.03 |