1 | 11654 | ์์คํค ์ฝ๋ |
public class Main {
public static void main(String[] args) throws Exception{
int a = System.in.read();
System.out.println(a);
}
}
2 | 11720 | ์ซ์์ ํฉ |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
int a[] = new int[scan.nextInt()];
int sum = 0;
String x = scan.next();
for(int i=0; i<a.length; i++) {
a[i] = x.charAt(i) -'0'; //charAt์ ์์คํค์ฝ๋๊ฐ์ ๋ฐํํ๊ธฐ์ '0'(48)์ ๋นผ์ค์ผํจ.
sum += a[i];
}
scan.close();
System.out.println(sum);
}
}
3 | 10809 | ์ํ๋ฒณ ์ฐพ๊ธฐ |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
String S = scan.nextLine();
scan.close();
for(int j = 97; j<123; j++) { //a์ ์์คํค์ฝ๋ =97, z์ ์์คํค์ฝ๋ = 122
for(int i = 0; i< S.length(); i++) {
int a = S.charAt(i);
if(a==j) {
System.out.print(i + " ");
break;
}
if(i == S.length()-1)
System.out.print("-1 ");
}
}
}
}
4 | 2675 | ๋ฌธ์์ด ๋ฐ๋ณต |
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException{
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
int T = Integer.parseInt(bfr.readLine());
for(int i=0; i<T; i++) {
String[] str = bfr.readLine().split(" ");
int R = Integer.parseInt(str[0]);
String x = str[1];
for(int j=0; j<x.length(); j++) {
for(int z = 0; z<R; z++)
System.out.print(x.charAt(j));
}
System.out.println();
}
}
}
5 | 1157 | ๋จ์ด ๊ณต๋ถ |
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
String input = bfr.readLine();
int a[] = new int [26];
bfr.close();
for(int i=0; i<input.length(); i++) {
if((int)input.charAt(i) >64 && (int)input.charAt(i) <91) {
a[(int)input.charAt(i)-65] +=1;
}
if((int)input.charAt(i) >96 && (int)input.charAt(i) <123) {
a[(int)input.charAt(i)-97] +=1;
}
}
int max = a[0];
int maxNumber = 0;
char output = (char)(maxNumber+65);
for(int i=1; i<26; i++) {
if(max < a[i]) {
max = a[i];
maxNumber = i;
output = (char)(maxNumber+65);
}
else if(max == a[i]) {
output = '?';
}
}
System.out.println(output);
}
}
6 | 1152 | ๋จ์ด์ ๊ฐ์ |
import java.io.*;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader bfr = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer stz = new StringTokenizer(bfr.readLine(), " ");
System.out.println(stz.countTokens());
// String a[] = bfr.readLine().split(" ");
// int output = a.length;
// if(a[0].equals(""))
// output -= 1;
// System.out.println(output);
// bfr.close();
}
}
7 | 2908 | ์์ |
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException{
int x[] = new int[2];
for(int i=0; i<2; i++) {
int a = System.in.read() -'0';
int b = System.in.read()-'0';
int c = System.in.read()-'0';
int line = System.in.read();
x[i] = c*100 + b*10 + a;
}
if(x[0] > x[1]) System.out.println(x[0]);
else System.out.println(x[1]);
}
}
8 | 5622 | ๋ค์ด์ผ |
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String T = scan.next();
scan.close();
char a[] = new char[T.length()];
int sum =0;
for(int i=0; i< T.length(); i++) {
a[i] = T.charAt(i);
if(a[i] >='A' && a[i]<='C') sum += 2;
else if(a[i] >='D' && a[i]<='F') sum += 3;
else if(a[i] >='G' && a[i]<='I') sum += 4;
else if(a[i] >='J' && a[i]<='L') sum += 5;
else if(a[i] >='M' && a[i]<='O') sum += 6;
else if(a[i] >='P' && a[i]<='S') sum += 7;
else if(a[i] >='T' && a[i]<='V') sum += 8;
else if(a[i] >='W' && a[i]<='Z') sum += 9;
else sum += 0;
}
System.out.println(sum + T.length());
}
}
9 | 2941 | ํฌ๋ก์ํฐ์ ์ํ๋ฒณ |
import java.util.Scanner;
public class Main {
public static void main(String[] args){
Scanner scan = new Scanner(System.in);
String a = scan.nextLine();
char x[] = new char[a.length()];
int count = 0;
for(int i = 0; i<a.length(); i++){
x[i] = a.charAt(i);
}
for(int i = 0; i<a.length(); i++) {
if(i<x.length-1) {
if(x[i] == 'c' && (x[i+1] == '-' || x[i+1] == '='))
i++;
if (x[i] == 'd') {
if(x[i+1] == '-')
i++;
else if (i< x.length-2)
if( x[i+1] == 'z' && x[i+2] == '=' )
i+=2;
}
if(x[i] == 'l' && x[i+1] == 'j')
i++;
if(x[i] == 'n' && x[i+1] == 'j')
i++;
if(x[i] == 's' && x[i+1] == '=')
i++;
if(x[i] == 'z' && x[i+1] == '=')
i++;
}
count++;
}
System.out.println(count);
scan.close();
}
}
10 | 1316 | ๊ทธ๋ฃน ๋จ์ด ์ฒด์ปค |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int count = 0;
String a[] = new String[scan.nextInt()];
for(int i=0; i<a.length; i++) {
a[i] = scan.next();
}
for(int i=0; i<a.length; i++) {
char x[] = new char[a[i].length()];
boolean pf = true;
for(int j=0; j<a[i].length(); j++) { //์
๋ ฅ๋ฐ์ ๋ฌธ์ฅ ๋ฐฐ์ด๋ก ์ชผ๊ฐ x[]
x[j] = a[i].charAt(j);
}
for(int z = 1; z< x.length; z++) {
if(x[z] != x[z-1]) { //๋ง์ฝ ๋ฐ๋ก ์ง์ ์ ๊ฐ๊ณผ ๋ค๋ฅด๋ฉด
for(int search = 0; search< z-1; search++) {
if(x[z] == x[search]) // ์ด์ ์ ํ๋ฒ์ด๋ผ๋ ๋์จ ๊ฐ์ด๋ฉด false๋ก ๋ฐ๊ฟ.
pf = false;
}
}
}
if(pf == true) count++;
}
System.out.println(count);
scan.close();
// }
//
// char x[i] = new char [a[i].length()];
// for(int i=0; i<T; i++) {
// x[i] = a[i].charAt(i);
// }
//
// for(int i = 0; i<a.length; i++) {
// if(x[i] == a[j]);
//
// }
}
}
728x90
๋ฐ์ํ