โ์ช ์ ํจ๊ป ํ๋ฃจ์ 30๋ถ ์ด์ ์์โจ
1157
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
int arr[] = new int[26]; //์๋ฌธ์์ ๊ฐ์
Scanner sc = new Scanner(System.in);
String b = sc.next();
for(int i = 0; i<b.length(); i++) {
if('A'<= b.charAt(i)&& b.charAt(i) <= 'Z') {//๋๋ฌธ์์ ๋ฒ์
arr[b.charAt(i) - 'A']++;//ํด๋น ์ธ๋ฑ์ค์ ๊ฐ 1 ์ฆ๊ฐ
}else { //์๋ฌธ์์ ๋ฒ์
arr[b.charAt(i) - 'a']++;
}
}
int max = -1;
char ch = '?';
for(int i =0; i< 26; i++) {
if(arr[i] > max) {
max = arr[i];
ch = (char)(i+65); //์บ์คํ
ํ์ , ๋๋ฌธ์๋ก ์ถ๋ ฅํ๊ธฐ ์ํด 65๋ฅผ ๋ํด์ค๋ค
}
else if(arr[i] == max) {
ch = '?';
}
}
System.out.print(ch);
}
}
1152
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) {
int arr[] = new int[26]; //์๋ฌธ์์ ๊ฐ์
Scanner sc = new Scanner(System.in);
String b = sc.nextLine();
StringTokenizer st = new StringTokenizer(b, " ");
System.out.println(st.countTokens());
}
}
2908
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
sc.close();
A = Integer.parseInt(new StringBuilder().append(A).reverse().toString());
//์์ฑ๊ณผ ๋์์ ๋ฉ์๋์ ๊ฐ์ ์
๋ ฅ ๋ฌธ์์ด์ ๋ค์ง์ด์ฃผ๊ณ ๋ฐํ์์ผ์ค๋ค
B = Integer.parseInt(new StringBuilder().append(B).reverse().toString());
System.out.print(A > B ? A : B);
}
}
5622
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String s = in.nextLine();
int count = 0;
int k = s.length();
for(int i = 0; i < k; i++) {
switch(s.charAt(i)) {
case 'A' : case 'B': case 'C' :
count += 3;
break;
case 'D' : case 'E': case 'F' :
count += 4;
break;
case 'G' : case 'H': case 'I' :
count += 5;
break;
case 'J' : case 'K': case 'L' :
count += 6;
break;
case 'M' : case 'N': case 'O' :
count += 7;
break;
case 'P' : case 'Q': case 'R' : case 'S' :
count += 8;
break;
case 'T' : case 'U': case 'V' :
count += 9;
break;
case 'W' : case 'X': case 'Y' : case 'Z' :
count += 10;
break;
}
}
System.out.print(count);
}
}
2941
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String str = in.nextLine();
int count = 0;
for (int i = 0; i < str.length(); i++) {
char ch = str.charAt(i);
if(ch == 'c') { // ๋ง์ฝ ch ๊ฐ c ๋ผ๋ฉด?
if(i < str.length() - 1) {
if(str.charAt(i + 1) == '=') { //๋ง์ฝ ch ๋ค์ ๋ฌธ์๊ฐ '=' ์ด๋ผ๋ฉด?
// i+1 ๊น์ง๊ฐ ํ๋์ ๋ฌธ์์ด๋ฏ๋ก ๋ค์ ๋ฌธ์๋ฅผ ๊ฑด๋ ๋ฐ๊ธฐ ์ํด 1 ์ฆ๊ฐ
i++;
}
else if(str.charAt(i + 1) == '-') {
i++;
}
}
}
else if(ch == 'd') {
if(i < str.length() - 1) {
if(str.charAt(i + 1) == 'z') {
if(i < str.length() - 2) {
if(str.charAt(i + 2) == '=') { // dz= ์ผ ๊ฒฝ์ฐ
i += 2;
}
}
}
else if(str.charAt(i + 1) == '-') { // d- ์ผ ๊ฒฝ์ฐ
i++;
}
}
}
else if(ch == 'l') {
if(i < str.length() - 1) {
if(str.charAt(i + 1) == 'j') { // lj ์ผ ๊ฒฝ์ฐ
i++;
}
}
}
else if(ch == 'n') {
if(i < str.length() - 1) {
if(str.charAt(i + 1) == 'j') { // nj ์ผ ๊ฒฝ์ฐ
i++;
}
}
}
else if(ch == 's') {
if(i < str.length() - 1) {
if(str.charAt(i + 1) == '=') { // s= ์ผ ๊ฒฝ์ฐ
i++;
}
}
}
else if(ch == 'z') {
if(i < str.length() - 1) {
if(str.charAt(i + 1) == '=') { // z= ์ผ ๊ฒฝ์ฐ
i++;
}
}
}
count++;
}
System.out.println(count);
}
}
1316
import java.util.Scanner;
public class Main {
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int count = 0;
int N = sc.nextInt();//๋จ์ด์ ๊ฐ์
for(int i =-0; i< N; i++) {
if(check()== true) {
count++;
}
}
System.out.println(count);
}
public static boolean check() {
boolean[] ch = new boolean[26];
int M = 0;
String str = sc.next();
for(int i=0; i<str.length(); i++) {
int now = str.charAt(i); // i๋ฒ์งธ ๋ฌธ์ ์ ์ฅ(ํ์ฌ ๋ฌธ์)
//์์ ๋ฌธ์์ i ๋ฒ์งธ ๋ฌธ์๊ฐ ๊ฐ์ง ์๋ค๋ฉด?
if(M != now) {
//ํด๋น ๋ฌธ์๊ฐ ์ฒ์ ๋์ค๋ ๊ฒฝ์ฐ(false์ธ ๊ฒฝ์ฐ)
if(ch[now - 'a']== false) {
ch[now - 'a'] = true; //true๋ก ๋ฐ๊ฟ์ค๋ค
M = now; //๋ค์ ํด์ ์ํด M๋ ๋ฐ๊ฟ์ค๋ค
}
//ํด๋น ๋ฌธ์๊ฐ ์ด๋ฏธ ๋์จ ์ ์ด ์๋ ๊ฒฝ์ฐ(๊ทธ๋ฃน๋จ์ด๊ฐ ์๋๊ฒ ๋จ)
else {
return false; //ํจ์ ์ข
๋ฃ
}
}
//์์ ๋ฌธ์์ i ๋ฒ์จฐ ๋ฌธ์๊ฐ ๊ฐ๋ค๋ฉด?(์ฐ์๋ ๋ฌธ์)
//else ๋ฌธ์ ์์ด๋ ๋จ
else {
continue;
}
}
return true;
}
}