[Programmers] 프로그래머스 SQL 고득점 Kit (입양 시각 구하기(1) - Oracle 해답)
·
Algorithm/Programmers
SELECT HOUR, COUNT(*) COUNT FROM (SELECT TO_CHAR(DATETIME, 'HH24') HOUR FROM ANIMAL_OUTS) HAVING HOUR >= 9 and HOUR < 20 GROUP BY HOUR ORDER BY HOUR MySQL 해답 보고 Oracle 문제 푸니까 현자타임이 왔다. 분명 쉬워보였는데 서브쿼리를 사용해서 풀어야했다. 학원 다닐때도 이 문제 풀다가 짜증만나서 포기했었는데 드디어 풀었다!
[Baekjoon Algorithm] 백준 알고리즘 1152번 단어의 개수
·
Algorithm/Baekjoon
public class Baekjoon1152 { public static void main(String[] args) { //String arr = "The Curious Case of Benjamin Button"; // String arr = "Oh My God"; String arr = "Ah Chiken Ah Chiken Ah Chiken Ah Chiken Ah Chiken Ah Chiken Ah Chiken ".trim(); int space = 0; int result = 0; for(int i = 0; i < arr.length(); i++) { if(arr.charAt(i) == ' ') { space++; } } System.out.print(space + 1); } } // 영어 대소..
[Baekjoon Algorithm] 백준 알고리즘 11654번 문자를 입력받아 해당 문자의 아스키코드를 출력하는 프로그램
·
Algorithm/Baekjoon
import java.util.Arrays; import java.util.Scanner; public class Baekjoon11654 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("문자를 입력하세요 : "); String abb = sc.nextLine(); System.out.print(Arrays.toString(abb.getBytes())); } } // 알파벳 소문자, 대문자, 숫자 0-9중 하나가 주어졌을 때, 주어진 글자의 아스키 코드값을 출력하는 프로그램을 작성하시오. 단순히 abb.getBytes() 로는 출력할 수 없기 때문에 값을 배열에 넣어 출력해준다
[Baekjoon Algorithm] 백준 알고리즘 8958번 1차원 배열을 이용한 OX퀴즈 점수 계산
·
Algorithm/Baekjoon
public class Baekjoon8958 { public static void main(String[] args) { // String[] ansArr = {"O", "O", "X", "X", "O", "X", "X", "O", "O", "O"}; String[] ansArr = {"O", "O", "O", "O", "X", "O", "O", "O", "O", "X", "O", "O", "O", "O", "X"}; int plus = 1; int finalCnt = 0; for(int i = 0; i < ansArr.length; i++) { if(ansArr[i].equals("O")) { finalCnt += plus; plus++; } else { plus = 1; } } System.out...
[Baekjoon Algorithm] 백준 알고리즘 3052번 배열의 나머지를 구한 뒤 서로 다른 값이 몇 개 있는지 출력하는 프로그램
·
Algorithm/Baekjoon
package list; import java.util.HashSet; public class Baekjoon3052 { public static void main(String[] args) { // 배열 생성 int[] existingArr = {39, 40, 41, 42, 43, 44, 82, 83, 84, 85}; int[] printArr = new int[10]; HashSet counting = new HashSet(); int count = 0; for(int i = 0; i < existingArr.length; i++) { printArr[i] = existingArr[i] % 42; // System.out.print(printArr[i] + " "); counting.add(print..
[Baekjoon Algorithm] 백준 알고리즘 2562번 배열의 최대값과 순번을 출력하시오
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon2562 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] sortArr = {1, 105, 10, 15, 20, 100, 55, 88, 99}; int maxValue = sortArr[0]; int rank = 1; for(int i = 0; i < sortArr.length; i++) { if(maxValue < sortArr[i]) { maxValue = sortArr[i]; rank++; } } System.out.print("최대값은 : " + maxValue + "\n순번은 : " + rank); } } /..
[Baekjoon Algorithm] 백준 알고리즘 10818번 문제 배열의 최대값, 최소값 구하기
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon10818 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int[] newArr; System.out.print("몇 개의 정수를 입력하시겠습니까? : "); int n = sc.nextInt(); newArr = new int[n]; for (int i = 0; i < newArr.length; i++) { System.out.print(i + "번째 정수를 입력하세요옹 : "); newArr[i] = sc.nextInt(); } int min = newArr[0]; int max = newArr[0]; for (int i ..
[Baekjoon Algorithm] 백준 알고리즘 1330번 문제 두 수 비교하기
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon1330 { public static void main(String[] args) { // 두 정수 A와 B가 주어졌을 때, A와 B를 비교하는 프로그램을 작성하시오. Scanner sc = new Scanner(System.in); System.out.print("첫번째 수를 입력해주세요 : "); int n1 = sc.nextInt(); sc.nextLine(); System.out.print("두번째 수를 입력해주세요 : "); int n2 = sc.nextInt(); if(n1 < n2) { System.out.print(""); } else { System.out.print("=="); } } } // 쉬운.. ..
[Baekjoon Algorithm] 백준 알고리즘 2741번 문제 1부터 n까지의 수 한줄씩 출력
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon2741 { public static void main(String[] args) { // 자연수 N이 주어졌을 때, 1부터 N까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. Scanner sc = new Scanner(System.in); System.out.print("N까지의 수를 입력하세요 : "); int n = sc.nextInt(); for(int i = 1; i
[Baekjoon Algorithm] 백준 알고리즘 2742번 문제 자연수 N이 주어졌을 때, N부터 1까지 한 줄
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon2742 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("N의 수를 입력해주세요 : "); int n = sc.nextInt(); for (int i = n; i >= 1; i-- ) { System.out.println(i); } // 기찍 N // 자연수 N이 주어졌을 때, N부터 1까지 한 줄에 하나씩 출력하는 프로그램을 작성하시오. } } n 찍기 를 성공적으로 풀었다면 설명할 필요가 없는 문제
[Baekjoon Algorithm] 백준 알고리즘 8393번 문제 1부터 n까지의 덧셈을 구하시오
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon8393 { public static void main(String[] args) { // n이 주어졌을 때, 1부터 n까지 합을 구하는 프로그램을 작성하시오. int result = 0; Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i = 1; i
[Baekjoon Algorithm] 백준 알고리즘 9498번 문제 시험점수를 입력받아 등급을 출력하시오
·
Algorithm/Baekjoon
import java.util.Scanner; public class Baekjoon9498 { public static void main(String[] args) { // 시험 점수를 입력받아 90 ~ 100점은 A, 80 ~ 89점은 B, 70 ~ 79점은 C, 60 ~ 69점은 D, 나머지 점수는 F를 출력하는 프로그램을 작성하시오. Scanner sc = new Scanner(System.in); System.out.print("숫자를 입력하세요 : "); int grade = sc.nextInt(); if(grade 89) { System.out.print("A 입니다."); } else if (grade > 79) { System.out.print("B 입니다."); } else if (gr..
[Baekjoon Algorithm] 백준 알고리즘 1008 번 문제 A / B 를 출력하시오
·
Algorithm/Baekjoon
무작정 수를 받아 나눈 뒤 출력하면 안된다는것을 배웠다. 때에 따라서 유연하게 형변환을 해줘야하며 나눠야하는 순서도 생각해야한다 import java.util.Scanner; public class Baekjoon1008 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.println("수를 입력하세요"); int a = sc.nextInt(); sc.nextLine(); System.out.print("다음 수를 입력하세요 \n"); int b = sc.nextInt(); System.out.print(a / (double) b); } } // 때에 따라서 형변환을 해줘야할 때도 있다는 것을..
헌일
'Algorithm' 카테고리의 글 목록 (5 Page)