본문 바로가기
반응형

java136

[프로그래머스 - JAVA] 평균 구하기 내 풀이 class Solution { public double solution(int[] arr) { double answer = 0; // int로 받아서 나눠봐야 소숫점 자리가 나오지 않기 때문에 double로 받아야한다. double sum = 0.0; for(int i : arr){ sum += i; } answer = sum/arr.length; return answer; } } 다른 사람 풀이 문제 개편 2023. 3. 26.
[프로그래머스 - JAVA] 자릿수 더하기 내 풀이 import java.util.*; public class Solution { public int solution(int n) { int answer = 0; String check = String.valueOf(n); for(int i = 0; i < check.length(); i++){ answer += Integer.parseInt(String.valueOf(check.charAt(i))); } // [실행] 버튼을 누르면 출력 값을 볼 수 있습니다. System.out.println(answer); return answer; } } 다른 사람 풀이 import java.util.*; public class Solution { public int solution(int n) { int a.. 2023. 3. 26.
[프로그래머스 - JAVA] 약수의 합 내 풀이 class Solution { public int solution(int n) { int answer = 0; for (int i = 1; i 2023. 3. 25.
[프로그래머스 - JAVA] 짝수와 홀수 내 풀이 class Solution { public String solution(int num) { String answer = ""; answer = num % 2 == 0 ? "Even" : "Odd"; return answer; } } 2023. 3. 25.
[프로그래머스 - JAVA] 나누어 떨어지는 숫자 배열 내 풀이 import java.util.List; import java.util.Arrays; import java.util.ArrayList; class Solution { public int[] solution(int[] arr, int divisor) { int[] answer = {}; // answer에 들어갈 값의 크기 확인 int count =0; // 나누어 떨어지는 값을 넣기 위한 List List check = new ArrayList(); // arr의 크기만큼 for문을 돌려서 나누어 떨어지는 값이 있다면 List에 담고 count 증가 for (int i = 0; i < arr.length; i++) { if (arr[i] % divisor == 0){ check.add(arr[i.. 2023. 3. 25.
[Java] IntelliJ+ Sptring boot + Maven + Thymeleaf + Oracle 프로젝트 시작하기(3) 이전글 https://greed-yb.tistory.com/138 [Java] IntelliJ+ Sptring boot + Maven + Thymeleaf + Oracle 프로젝트 시작하기(2) 이전 글 https://greed-yb.tistory.com/137 [Java] IntelliJ+ Sptring boot + Maven + Thymeleaf + Oracle 프로젝트 시작하기(1) IntelliJ Ultimate 로 진행하였다 https://www.jetbrains.com/ko-kr/idea/download/#section=windows IntelliJ IDEA 다운로 greed-yb.tistory.com Vo 생성 src -> main -> java -> com -> example -> demo.. 2023. 3. 25.
반응형