본문 바로가기

백준 온라인 저지19

[BOJ_JAVA] 백준 7568번 : 덩치 @달깅 이 문제 진짜 몇 안되는 한 번에 맞았습니다!!! 가 뜬 문제다 ㅎㅎㅎ.. 이번엔 제네릭을 사용해서 풀어봤다! 어레이도 편하지만 제네릭에도 익숙해 져야 할 것 같당..! 앞으로는 다양하게 써서 문제를 풀어봐야겠다 하하 정답코드 import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int num=sc.nextInt(); int count=0; ArrayList weight=new ArrayList(); ArrayList height=new ArrayList(); ArrayList dung=new ArrayList(); for (int i=0; i 2019. 11. 5.
[BOJ_JAVA] 백준 2798번 : 블랙잭 @달깅 되게 쉬운 줄 알았는데 처음에 내가 막 for문 밖에서 더해주고 빼고를 하다가 생각해보니까 그럴필요가 없었다.. 되게 바보같았다 별표해둠..ㅠㅠ흑흑 정답코드 import java.util.*; public class Test { public static int black(int[] arr, int n,int m) { int sum=0; int ans=0; for (int i=0; i 2019. 11. 5.
[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.