알고리즘 3

백준 - 10869(사칙연산)

# 문제 https://www.acmicpc.net/problem/10869 10869번: 사칙연산 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오. www.acmicpc.net # JAVA import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int A = scan.nextInt(); int B = scan.nextInt(); System.out.println(A+B); System.out.println(A-B); System.out.println(A*B..

카테고리 없음 2021.09.22

프로그래머스 - 베스트앨범

# JAVA import java.util.HashMap; import java.util.ArrayList; import java.util.Collections; class Music { String genre; int play; int idx; public Music(String genre, int play, int idx) { this.genre = genre; this.play = play; this.idx = idx; } } class Solution { public int[] solution(String[] genres, int[] plays) { // 노래를 수록하는 기준 // 1. 속한 노래가 많이 재생된 장르를 먼저 수록합니다. // 2. 장르 내에서 많이 재생된 노래를 먼저 수록합니다. ..

선택&삽입&버블 정렬

# 코드 및 logic public class sort { public static void main(String[] args) { int[] input = { 5, 3, 2, 5, 6, 7, 1, 32, 67, 434, 995 }; print("input", input); // 주석 단축키 ctrl + / // selection(input); // insertion(input); bubble(input); } /** * logic * 1. 정렬되지 않은 인덱스의 맨 앞에서부터, 이를 포함한 그 이후의 배열값 중 가장 작은 값을 찾아간다 * (정렬되지 않은 인덱스의 맨 앞은, 초기 입력에서는 배열의 시작위치일 것이다.) * 2. 가장 작은 값을 찾으면, 그 값을 현재 인덱스의 값과 바꿔준다. * 3. 다..

IT/관련지식 2020.07.24