본문 바로가기

Problem Solving166

[백준 알고리즘] 11654: 아스키 코드 풀이(자바) 문제 https://www.acmicpc.net/problem/11654 11654번: 아스키 코드 알파벳 소문자, 대문자, 숫자 0-9중 하나가 주어졌을 때, 주어진 글자의 아스키 코드값을 출력하는 프로그램을 작성하시오. www.acmicpc.net 코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String character = sc.next(); int a = (int)character.charAt(0); System.out.println(a); sc.close(); } } 코드 설명 int a = (int)characte.. 2021. 8. 25.
[백준 알고리즘] 1065: 한수 풀이(자바) 문제 https://www.acmicpc.net/problem/1065 1065번: 한수 어떤 양의 정수 X의 각 자리가 등차수열을 이룬다면, 그 수를 한수라고 한다. 등차수열은 연속된 두 개의 수의 차이가 일정한 수열을 말한다. N이 주어졌을 때, 1보다 크거나 같고, N보다 작거나 www.acmicpc.net 코드 import java.util.Scanner; //등차수열: an = a1 + (n - 1)d class Test { int num = 0; int gap = 0; int cnt = 0;//한수의 갯수 카운트 void hanSoo(int n) { if(n < 100) {//n이 1~99일 때는 무조건 카운트 1씩 증가 for(int i = 0; i < n; i++) cnt++; } else.. 2021. 8. 25.
[백준 알고리즘] 15596: 정수 N개의 합 풀이(자바) 문제 https://www.acmicpc.net/problem/15596 15596번: 정수 N개의 합 C++17, Java 8, Python 3, C11, PyPy3, C99, C++98, C++11, C++14, Python 2, PyPy2, Go, C99 (Clang), C++98 (Clang), C++11 (Clang), C++14 (Clang), C11 (Clang), C++17 (Clang) www.acmicpc.net 코드 class Test { long sum(int[] a) { long ans = 0; for(int i = 0; i < a.length; i++) { ans += a[i]; } return ans; } } 2021. 8. 3.
[백준 알고리즘] 4344: 평균은 넘겠지 풀이(자바) 문제 https://www.acmicpc.net/problem/4344 4344번: 평균은 넘겠지 대학생 새내기들의 90%는 자신이 반에서 평균은 넘는다고 생각한다. 당신은 그들에게 슬픈 진실을 알려줘야 한다. www.acmicpc.net 코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt();//테스트 케이스 수 int sum, cnt; double avg; for(int i = 0; i < test; i++) {//테스트 케이스 수 만큼 반복 int sNum = sc.nextInt();//.. 2021. 8. 3.
[백준 알고리즘] 8958: OX퀴즈 풀이(자바) 문제 https://www.acmicpc.net/problem/8958 8958번: OX퀴즈 "OOXXOXXOOO"와 같은 OX퀴즈의 결과가 있다. O는 문제를 맞은 것이고, X는 문제를 틀린 것이다. 문제를 맞은 경우 그 문제의 점수는 그 문제까지 연속된 O의 개수가 된다. 예를 들어, 10번 문제의 점수 www.acmicpc.net 코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt();//테스트 케이스 수 String [] quiz = new String[test]; for(int i =.. 2021. 8. 2.
[백준 알고리즘] 1546: 평균(자바) 문제 https://www.acmicpc.net/problem/1546 1546번: 평균 첫째 줄에 시험 본 과목의 개수 N이 주어진다. 이 값은 1000보다 작거나 같다. 둘째 줄에 세준이의 현재 성적이 주어진다. 이 값은 100보다 작거나 같은 음이 아닌 정수이고, 적어도 하나의 값은 0보 www.acmicpc.net 코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int test = sc.nextInt();//과목 수 double sum = 0;//시험점수 총점 double[] score = new double[test];.. 2021. 8. 1.
[백준 알고리즘] 3052: 나머지 풀이(자바) 문제 https://www.acmicpc.net/problem/3052 3052번: 나머지 각 수를 42로 나눈 나머지는 39, 40, 41, 0, 1, 2, 40, 41, 0, 1이다. 서로 다른 값은 6개가 있다. www.acmicpc.net 코드 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int remain[] = new int[10]; int count = 0; for (int i = 0; i < remain.length; i++) { remain[i] = sc.nextInt(); remain[i] = remain[i] .. 2021. 8. 1.
[백준 알고리즘] 2577: 숫자의 개수 풀이(자바) 문제 문제 출처: https://www.acmicpc.net/problem/2577 2577번: 숫자의 개수 첫째 줄에 A, 둘째 줄에 B, 셋째 줄에 C가 주어진다. A, B, C는 모두 100보다 크거나 같고, 1,000보다 작은 자연수이다. www.acmicpc.net 코드 #1. 일일이 구하기 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int num1 = sc.nextInt(); int num2 = sc.nextInt(); int num3 = sc.nextInt(); int cnt0 = 0, cnt1 = 0, cnt2 =.. 2021. 7. 29.
알고리즘 사이트 모음 알고리즘 사이트 모음 프로그래머스: https://programmers.co.kr/learn/challenges HackerRank: https://www.hackerrank.com/ LeetCode: https://leetcode.com/ 코드그라운드: https://www.codeground.org/about 사이냅: http://euler.synap.co.kr/ Topcoder: https://www.topcoder.com/ 알고스팟: https://algospot.com/judge/problem/list/ Baekjoon 알고리즘: https://www.acmicpc.net/ SW Expert Academy: https://www.swexpertacademy.com/main/main.do geek.. 2021. 7. 28.
[백준|자바] 2884: 알람시계 (if문 활용) 문제 https://www.acmicpc.net/problem/2884 2884번: 알람 시계 상근이는 매일 아침 알람을 듣고 일어난다. 알람을 듣고 바로 일어나면 다행이겠지만, 항상 조금만 더 자려는 마음 때문에 매일 학교를 지각하고 있다. 상근이는 모든 방법을 동원해보았지만, www.acmicpc.net 실행화면 코드 import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int h = sc.nextInt(); //'시'를 입력받는 변수 int m = sc.nextInt(); //'분'을 입력받는 변수 if (m>=45) { System.. 2020. 11. 9.
반응형