728x90
반응형
SMALL
형성평가1 : 182
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char a = sc.next().charAt(0), b = sc.next().charAt(0);
System.out.print(((int)a + (int)b) + " " + (Math.abs((int)a - (int)b)) );
}
}
형성평가2 : 183
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
System.out.println(str.substring(0,5));
}
}
형성평가3 : 184
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String answer = "";
char[] arr = str.toCharArray();
for(char i : arr){
if(Character.isDigit(i)) answer += i;
else if(((int)i >= 65 && (int) i <=90) || ((int)i >= 97 && (int)i <=122)) answer += Character.toLowerCase(i);
}
System.out.println(answer);
}
}
형성평가4 : 185
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
char s = sc.next().charAt(0);
char[] arr = str.toCharArray();
boolean a = true;
for(int i = 0; i < arr.length; i++){
if(arr[i] == s){
a = false;
System.out.println(i);
break;
}
}
if(a) System.out.println("No");
}
}
형성평가5 : 186
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] arr = sc.nextLine().split("\\s+");
int max = 0;
for(String i : arr){
max = max > i.length() ? max : i.length();
}
System.out.println(max);
}
}
형성평가6 : 187
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
int a;
while(str.length() > 1){
a = sc.nextInt();
if(a >= str.length()) str = str.substring(0, str.length() -1);
else str = str.substring(0,a-1)+str.substring(a);
System.out.println(str);
}
}
}
형성평가7 : 188
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String li = sc.nextLine().trim();
String[] arr = li.split("\\s+");
int i = 1;
for(String a : arr){
System.out.println(i+". " + a);
i++;
}
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 189 ~ 194 && 215, 216, 237 : 문자열2 - 형성평가 1 ~ 9 (1) | 2023.10.04 |
---|---|
[자바] 정올 602~ 612 : 문자열2 - 자가진단1 ~ 11 (0) | 2023.10.04 |
[자바] 정올 593 ~ 601 : 문자열1 - 자가진단1~9 (1) | 2023.10.04 |
[자바] 정올 231 ~ 236 : 함수3 - 형성평가1~6 (0) | 2023.10.03 |
[자바] 정올 587 ~ 592 : 함수3 - 자가진단1~6 (1) | 2023.10.03 |