Ruby

https://www.acmicpc.net/problem/2525 오븐 시계 문제 요약 / 풀이 방법 하루는 1440분이므로 분으로 전부 변경후 연산하면 편하게 연산 가능함 코드 def Q_2525() time = gets.chomp.split(" ") open_minute = gets.chomp.to_i minute = time[0].to_i * 60 + time[1].to_i + open_minute if minute >= 1440 minute = minute - 1440 end hour = minute/60 minute = minute%60 puts "#{hour} #{minute}" end Q_2525()
https://www.acmicpc.net/problem/2884 알람 시계 문제 요약 하루는 1440분이므로 분으로 전부 변경후 연산하면 편하게 연산 가능함 코드 def Q_2884() time = gets.chomp.split(" ") minute = time[0].to_i * 60 + time[1].to_i - 45 if minute < 0 minute = minute + 1440 end hour = minute/60 minute = minute%60 puts "#{hour} #{minute}" end Q_2884()
https://www.acmicpc.net/problem/14681 사분면 고르기 def Q_14681() x = gets.chomp.to_i y = gets.chomp.to_i if x > 0 and y > 0 puts 1 elsif x 0 puts 2 elsif x > 0 and y < 0 puts 4 else puts 3 end end Q_14681()
https://www.acmicpc.net/problem/2753 윤년 def Q_2753() year = gets.chomp.to_i if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0 puts "1" else puts "0" end end Q_2753()
https://www.acmicpc.net/problem/9498 시험 성적 def Q_9498() jumsu = gets.chomp.to_i if jumsu >= 90 puts "A" elsif jumsu >= 80 puts "B" elsif jumsu >= 70 puts "C" elsif jumsu >= 60 puts "D" else puts "F" end end Q_9498()
https://www.acmicpc.net/problem/1330 두 수 비교하기 def Q_1330() str = gets.chomp.split(" ") numA = str[0].to_i numB = str[1].to_i if numA > numB puts ">" elsif numA < numB puts "
https://www.acmicpc.net/problem/25083 def Q_25083() puts " ,r&#39;\"7\n" + "r`-_ ,&#39; ,/\n" + " \\. \". L_r&#39;\n" + " `~\\/\n" + " |\n" + " |" end Q_25083()
https://www.acmicpc.net/problem/10172 개 def Q_10172() puts "|\\_/|\n" + "|q p| /}\n" + "( 0 )\"\"\"\\\n" + "|\"^\"` |\n" + "||_/=\\\\__|" end Q_10172()
작심삼일 금지령
'Ruby' 카테고리의 글 목록 (2 Page)