본문 바로가기

아기 개발자/백준 문제풀이18

[BOJ_JAVA] 백준 10870번 : 피보나치 수 5 @달깅 피보나치 수도 항상 수업시간에 배우는 재귀함수.. 그래도 다시 짜보려고 하니까 헷갈렸다! 내가 피보나치 수를 잘 몰라서 그런것..ㅠㅠ 정답코드 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n=sc.nextInt(); System.out.println(fibo(n)); } public static int fibo(int n) { if (n==0) { return 0; } else if (n==1 || n==2) { return 1; } else { return fibo(n-1)+fibo(n-2); } } } 피보나치 수 정복ㅎ 2019. 11. 4.
[BOJ_JAVA] 백준 1712번 : 손익분기점 @달깅 누가 롱으로 해야된다길래 했다가 런타임 에러 떠서 그냥 인티저로 하니까 잘 되더라! 정답코드 import java.util.*; public class Main{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); int a=sc.nextInt(); int b=sc.nextInt(); int c=sc.nextInt(); if (c 2019. 11. 4.
[BOJ_JAVA] 백준 1316번 : 그룹 단어 체커 @달깅 처음에는 문제를 잘 못 읽어서 알파벳 순서대로 나와야한다는 줄 알았다. 간단한 문제! 정답코드 import java.util.*; public class Main { private static int count=0; public static boolean group(String str) { boolean avail=true; int[] alpha=new int[26]; int currint; char currchar=' '; for (int i=0; i 2019. 11. 4.
[BOJ_JAVA] 백준 2941번 : 크로아티아 알파벳 @달깅 아니 처음에 이제 작성을 딱 했는데 다 맞게 한 거 같은데 도대체가 반례가 안찾아졌다..ㅠㅠㅠㅠㅠ 게시판에 있는 반례들 대부분 다 제대로 되는데 왜 안되는 지 모르겠는거..ㅜㅜㅜ 근데 알고봤더니 ㅎㅎ 하나 조건을 == 으로 적어놨었다~~ 정답코드 #해법1. import java.util.*; public class Test{ public static void main(String[] args) { Scanner sc=new Scanner(System.in); String input=sc.nextLine(); int count=0; for (int i=0; i 2019. 11. 4.