https://www.acmicpc.net/problem/2908
2908번: 상수
상근이의 동생 상수는 수학을 정말 못한다. 상수는 숫자를 읽는데 문제가 있다. 이렇게 수학을 못하는 상수를 위해서 상근이는 수의 크기를 비교하는 문제를 내주었다. 상근이는 세 자리 수 두
www.acmicpc.net
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int x = in.nextInt();
int y = in.nextInt();
int xx = flip(x);
int yy = flip(y);
System.out.println(xx > yy ? xx : yy);
}
public static int flip(int num){
int result=0;
while(num!=0){
result= result * 10 + num % 10;
num /= 10;
}
return result;
}
}
https://www.acmicpc.net/problem/5622
5622번: 다이얼
첫째 줄에 알파벳 대문자로 이루어진 단어가 주어진다. 단어의 길이는 2보다 크거나 같고, 15보다 작거나 같다.
www.acmicpc.net
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String x = in.nextLine();
int time = 0;
for(int i=0; i<x.length(); i++) {
if(x.charAt(i) < 83 ) {
time += (((x.charAt(i) - 62) / 3) + 2);
}
else if(x.charAt(i) >= 83 && x.charAt(i) < 90){
time += (((x.charAt(i) - 63) / 3) + 2);
}
else {
time += 10;
}
}
System.out.println(time);
}
}
https://www.acmicpc.net/problem/10809
10809번: 알파벳 찾기
각각의 알파벳에 대해서, a가 처음 등장하는 위치, b가 처음 등장하는 위치, ... z가 처음 등장하는 위치를 공백으로 구분해서 출력한다. 만약, 어떤 알파벳이 단어에 포함되어 있지 않다면 -1을 출
www.acmicpc.net
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String x = in.nextLine();
int count = 0;
int arr[] = new int[26];
for(int i=0; i<26; i++) {
arr[i] = -1;
}
for(int i=0; i< x.length(); i++) {
if(arr[x.charAt(i)-97] == -1) {
arr[x.charAt(i)-97] = count;
}
count++;
}
for(int i=0; i<26; i++) {
System.out.print(arr[i] + " ");
}
}
}
'Java-Study' 카테고리의 다른 글
Java Study : 7주차 - 백준 문제풀이 (0) | 2022.12.23 |
---|---|
Java Stduy : 7주차 정리 - 기본 클래스(Object, String, Wrapper, Class 클래스) (0) | 2022.12.23 |
Java Study : 6주차 정리 - 인터페이스 (0) | 2022.12.09 |
Java Study : 5주차 - 백준 문제풀이 (0) | 2022.12.02 |
Java Study : 5주차 정리 - 추상 클래스 (1) | 2022.12.02 |