[프로그래머스] 약수의 합(Java) 나의 풀이class Solution { public int solution(int n) { int answer = 0; for(int i=1; i 다른 사람의 풀이class SumDivisor { public int sumDivisor(int num) { int answer = 0; for (int i = 1; i num / 2보다 큰 수는 약수가 될 수 없기 때문에 num의 절반까지만 반복한다.모든 약수의 합이므로 본인 num도 더함. 알고리즘 2024.10.29
[프로그래머스] 평균 구하기(Java) 나의 풀이class Solution { public double solution(int[] arr) { double answer = 0; for(int i=0; i 다른 사람의 풀이class Solution { public double solution(int[] arr) { int sum = 0; for (int i:arr) sum += i; return (double) sum / arr.length; }} 알고리즘 2024.10.28
TIL 241028 오늘 한 것 자바 스터디boolean 타입, 논리 연산자알고리즘 0){ answer += n % 10; n = n / 10; } return answer; }} 다른 사람의 풀이import java.util.*;public class Solution { public int solution(int n) { int answer" data-og-host="muerha.tistory.com" data-og-source-url="https://muerha.tistory.com/35" data-og-url="https://muerha.tistory.com/35" data-og-image="https://scrap.kakaocdn.net/dn/bhvmxc/hyXpu28Obb/K1n2FVJfOfUe2ej0BChw.. TIL 2024.10.28
[프로그래머스] 자릿수 더하기(Java) * 나의 풀이public class Solution { public int solution(int n) { int answer = 0; while(n > 0){ answer += n % 10; n = n / 10; } return answer; }} 다른 사람의 풀이import java.util.*;public class Solution { public int solution(int n) { int answer = 0; String str = Integer.toString(n); for (int i = 0; i str.substring(i, i + 1).. 알고리즘 2024.10.28
[프로그래머스] 짝수와 홀수(Java) 나의 풀이class Solution { public String solution(int num) { String answer = ""; if(num % 2 == 0){ answer = "Even"; }else{ answer = "Odd"; } return answer; }} 다른 사람의 풀이class Solution { public String solution(int num) { return num % 2 == 0 ? "Even":"Odd"; }} 알고리즘 2024.10.26
TIL 241025 오늘 한 것 자바 스터디개인 과제 트러블슈팅 작성, 제출 개인과제 트러블슈팅 - 숫자 야구 게임Java를 활용한 숫자 야구 게임을 만들던 도중 정답을 맞추고 나면 종료와 재시작을 선택할 수 있도록 하는 로직을 작성 하지만 정답을 맞춘 후 사용자의 입력을 받지 않고 Exception in thread "main" jamuerha.tistory.com 알고리즘 코드카타 [프로그래머스] 배열의 평균값(Java)나의 풀이class Solution { public double solution(int[] numbers) { double answer = 0; double result = 0; for(int i=0 ; i 다른 사람의 풀이class Solution { public double solution(.. TIL 2024.10.25
[프로그래머스] 배열의 평균값(Java) 나의 풀이class Solution { public double solution(int[] numbers) { double answer = 0; double result = 0; for(int i=0 ; i 다른 사람의 풀이class Solution { public double solution(int[] numbers) { double answer = 0; for(int i = 0 ; i 불필요한 연산을 줄이고 조금 더 간결하게 코드를 짜는 연습이 필요할 것 같다.. 알고리즘 2024.10.25
개인과제 트러블슈팅 - 숫자 야구 게임 Java를 활용한 숫자 야구 게임을 만들던 도중 정답을 맞추고 나면 종료와 재시작을 선택할 수 있도록 하는 로직을 작성 하지만 정답을 맞춘 후 사용자의 입력을 받지 않고 Exception in thread "main" java.util.NoSuchElementException 오류가 발생하는 것을 알게되었고 해당 오류가 발생하는 원인을 찾아보던 중 public void play() { Scanner sc = new Scanner(System.in); System.out.println(); System.out.println(""); while (true) { List inputNumberList; Set inputN.. 내배캠 2024.10.25
TIL 241024 오늘 한 것 자바 스터디윤년 판단 함수static boolean isLeapYear(int year){ if( year % 4 == 0 && year % 100 != 0){ return true; } if(year % 400 == 0){ return true; } return false;} 별찍기 첫째 줄에는 별 1개, 둘째 줄에는 별 2개, N번째 줄에는 별 N개를 찍는 문제private static void printStar(int n) { for (int i = 1; i 알고리즘 코드카타 [프로그래머스] 짝수의 합(Java)나의 풀이class Solution { public int solution(int n) { int answer = 0; for(int i = .. TIL 2024.10.24
[프로그래머스] 짝수의 합(Java) 나의 풀이class Solution { public int solution(int n) { int answer = 0; for(int i = 2 ; i 다른 사람의 풀이class Solution { public int solution(int n) { int answer = 0; for(int i=2; i 알고리즘 2024.10.24