개발자가 되기까지 (2023.08.16~2024.04.15)/[Algorithm] Programmers ver.Java2023. 12. 23. 20:43프로그래머스 Lv.0 피자 나눠 먹기 (3)
class Solution { public int solution(int slice, int n) { int answer = (int) Math.ceil( (double) n / slice); return answer; } }
개발자가 되기까지 (2023.08.16~2024.04.15)/[Algorithm] Programmers ver.Java2023. 12. 23. 20:29프로그래머스 Lv.0 세균 증식
class Solution { public int solution(int n, int t) { int answer = n * (int) Math.pow(2, t); return answer; } }
개발자가 되기까지 (2023.08.16~2024.04.15)/[Basic] Java2023. 8. 30. 17:11[Java] 주사위 던지기 (Math.random(), switch)
1~6까지의 수를 랜덤으로 추출하여 '주사위 : 1칸 전진' 출력 public class SwitchRandom { public static void main(String[] args) { // 1~6까지의 랜덤 생성 int dice = (int)(Math.random()*6)+1; //랜덤 수에 따른 출력 switch(dice) { case 1: System.out.println("주사위 : "+dice+"칸 전진"); break; case 2: System.out.println("주사위 : "+dice+"칸 전진"); break; case 3: System.out.println("주사위 : "+dice+"칸 전진"); break; case 4: System.out.println("주사위 : "+dic..