백준 1157번 (bronze 1)
import java.util.Scanner;
public class problem32 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 알파벳의 갯수가 26개이다
int [] alphabet = new int[26];
String inputString = in.next();
for (int i = 0; i < inputString.length(); i++) {
if('A' <= inputString.charAt(i) &&
inputString.charAt(i) <= 'Z'){
// 대문자
// 26개 인덱스 중 해당 인덱스를 알파벳 갯수만큼 증가해준다.
// - 'A'로 한 이유는 알파벳은 A보다 큼
alphabet[inputString.charAt(i) - 'A']++;
}
else{
//소문자
alphabet[inputString.charAt(i) - 'a']++;
}
}
// -1 인 이유는 26개 알파벳중 입력되지 않은 알파벳이 있을수 있음으로
int max = -1;
char temp = '?';
// aa bb = ?
for (int i = 0; i < 26; i++) {
if (alphabet[i] > max){
max = alphabet[i];
// 대문자로 출력해야됨으로 65를 더해준다.
temp = (char) (i + 65);
} else if (alphabet[i] == max) {
temp = '?';
}
}
System.out.println(temp);
}
}
백준 1259번 (bronze 1)
import java.util.Scanner;
public class problem33 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while(true){
String input = in.next();
boolean check = true;
if(input.equals("0")) break;
for (int i = 0; i < input.length()/ 2; i++) {
// 1234321 --> 앞의 123, 뒤의 321을 index에 맞춰 비교
if(input.charAt(i) !=
input.charAt(input.length() - 1 - i)) check = false;
}
if (check) System.out.println("yes");
else System.out.println("no");
}
}
}
백준 1292번 (bronze 1)
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class problem34 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int first = in.nextInt();
int second = in.nextInt();
List<Integer> numberList = new ArrayList<>();
for (int i = 0; i < 1001; i++) {
for (int j = 0; j <= i; j++) {
numberList.add(i + 1);
}
}
int sum = 0;
// List 임으로 index에 맞춰 구현
for (int i = first - 1; i <= second - 1; i++) {
sum += numberList.get(i);
}
System.out.println(sum);
}
}
백준 1357번 (bronze 1)
import java.util.Scanner;
public class problem35 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int first = in.nextInt();
int second = in.nextInt();
in.close();
int total = reverse(reverse(first) + reverse(second));
System.out.println(total);
}
static int reverse(int number){
int a = 0;
// 자릿수를 뒤집기 위해 구현
while(number > 0){
a = (a * 10) + (number % 10);
number /= 10;
}
return a;
}
}