RunDevOps
close
프로필 배경
프로필 로고

RunDevOps

  • 분류 전체보기
    • 한화시스템 백엔드 SW교육
    • JAVA STUDY
      • 백준
      • 프로그래머스
      • JAVA Practice
      • Spring
    • DB STUDY
      • 프로그래머스
      • DB Practice
    • Cloud
      • AWS
      • AWS-SAA(C03)
    • Computer Science
    • SW_ENGINEERING STUDY
    • Certificate
    • Run
  • 홈
  • GitHub

프로그래머스 배열 자르기 문제

정수 배열 numbers와 정수 num1, num2가 매개변수로 주어질 때, numbers의 num1번 째 인덱스부터 num2번째 인데스까지 자른 정수 배열을 return class Solution { public int[] solution(int[] numbers, int num1, int num2) { int[] answer = new int[num2 - num1 + 1]; for(int i=num1, j=0; i

  • format_list_bulleted JAVA STUDY/프로그래머스
  • · 2023. 12. 15.
  • textsms

프로그래머스 자릿수 더하기 문제

class Solution { public int solution(int n) { int answer = 0; // 주어진 수 n을 자릿수마다 나눠서 더합니다. while (n > 0) { answer += n % 10; // 현재 자릿수의 숫자를 더함 n /= 10; // 다음 자릿수로 이동 } return answer; } } - 현재 자릿수의 숫자를 더함 주어진 정수 n을 10으로 나눈 나머지값은 1의자리 숫자이다. 때문에 answer에 계속 현재 자릿수의 숫자를 더해준다. - 다음 자릿수 이동 주어진 정수 n을 10으로 나누면 1의자리 숫자가 소수점 첫째 자리가 되고 나눈 값을 int형인 answer에 넣으면 원래 10의 자리였던 수가 1의 자리로 오고 원래 1의자리였던 수는 없어지게된다. 즉, ..

  • format_list_bulleted JAVA STUDY/프로그래머스
  • · 2023. 12. 15.
  • textsms

프로그래머스 제곱수 판별하기

import java.lang.Math; class Solution { public int solution(int n) { double a = Math.sqrt(n); if(a == (int)a) { return 1; } else { return 2; } } } Math.sqrt() = 자바 제곱근(루트)구하기, 입력값과 출력값은 모두 double형 제곱수는 루트를 씌우면 정수가 나올 것이기 때문에 if문에 '루트 값이 정수이면' 이라는 조건문을 작성했다.

  • format_list_bulleted JAVA STUDY/프로그래머스
  • · 2023. 12. 15.
  • textsms

프로그래머스 문자열 뒤집기 문제

class Solution { public String solution(String my_string) { // my_string이라는 문자열을 char 형식의 배열로 변환하여 배열 a에 저장 char[] a = my_string.toCharArray(); // 문자 배열 뒤집기 for (int i = 0, j = a.length - 1; i < j; i++, j--) { char temp = a[i]; a[i] = a[j]; a[j] = temp; } // 뒤집힌 문자 배열을 문자열로 변환하여 출력 String answer = new String(a); return answer; } } - toCharArray : String 문자열을 char형 문자 배열로 바꿔서 반환해주는 메서드 - toCharAr..

  • format_list_bulleted JAVA STUDY/프로그래머스
  • · 2023. 12. 15.
  • textsms

프로그래머스 배열 원소의 길이 문제

class Solution { public int[] solution(String[] strlist) { int[] answer = new int[strlist.length]; for(int i = 0; i < strlist.length; i++) { answer[i] = strlist[i].length(); } return answer; } } - 주어진 문자열 배열의 길이만큼 정수 배열을 선언 - 문자열의 길이를 계산하여 정수 배열에 저장합니다. - 계산된 정수 배열을 반환

  • format_list_bulleted JAVA STUDY/프로그래머스
  • · 2023. 12. 14.
  • textsms

프로그래머스 옷가게 할인 받기 문제

class Solution { public int solution(int price) { if(price >= 500000) { double answer = (double) price * 0.80; return (int) answer; } if(price >= 300000) { double answer = (double) price * 0.90; return (int) answer; } if(price >= 100000) { double answer = (double) price * 0.95; return (int) answer; } return price; } } if문 = {}문 열기, if 문이 연속될 때 중괄호 한줄띄기 'public int~' 메소드가 최종적으로 int 타입으로 값을 받기 때문에..

  • format_list_bulleted JAVA STUDY/프로그래머스
  • · 2023. 12. 14.
  • textsms
  • navigate_before
  • 1
  • 2
  • 3
  • 4
  • 5
  • navigate_next
전체 카테고리
  • 분류 전체보기
    • 한화시스템 백엔드 SW교육
    • JAVA STUDY
      • 백준
      • 프로그래머스
      • JAVA Practice
      • Spring
    • DB STUDY
      • 프로그래머스
      • DB Practice
    • Cloud
      • AWS
      • AWS-SAA(C03)
    • Computer Science
    • SW_ENGINEERING STUDY
    • Certificate
    • Run
최근 글
인기 글
전체 방문자
오늘
어제
전체
Copyright © 쭈미로운 생활 All rights reserved.
Designed by JJuum

티스토리툴바