728x90
반응형
SMALL
자가진단1 : 593
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = 33;
while(true){
System.out.print("ASCII code =? ");
a = sc.nextInt();
if(a >=33 && a <= 127) System.out.println((char)a);
else break;
}
}
}
자가진단2 : 594
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String my = sc.nextLine();
System.out.println(my.repeat(2));
}
}
자가진단3 : 595
public class Main {
public static void main(String[] args) {
String str = "Hong Gil Dong";
System.out.println(str.substring(3,7));
}
}
자가진단4
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.next();
int i = sc.nextInt();
if( i >= str.length()){
for(int j = str.length() -1; j >= 0; j--) System.out.print(str.charAt(j));
}else{
for(int j = str.length() -1; j > str.length() -1 - i; j--) System.out.print(str.charAt(j));
}
}
}
자가진단5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int sum = 0;
String str;
for(int i = 0; i < 2; i++){
str = sc.nextLine();
sum += str.length();
}
System.out.println(sum);
}
}
자가진단6
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char a;
while (true) {
a = sc.next().charAt(0);
if ( ((int)a >= 65 && (int)a <= 90) || ((int)a >= 97 && (int)a <= 122)) System.out.println(a);
else if (Character.isDigit(a)) System.out.println((int)a);
else break;
}
}//end main()
}
자가진단7
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 = "";
for(int i = 0;i<str.length();i++){
if(((int)str.charAt(i) >= 65 && (int)str.charAt(i) <= 90) || ((int)str.charAt(i) >= 97 && (int)str.charAt(i) <= 122)) answer += str.charAt(i);
}//end for
System.out.println(answer.toUpperCase());
}
}
자가진단8
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
String[] arr = str.split( " ");
System.out.println(arr.length);
}
}
자가진단9
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
for(int i = 1; i < str.length(); i++){
System.out.print(str.substring(str.length()-i));
System.out.println(str.substring(0, str.length()-i));
}
System.out.println(str);
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 602~ 612 : 문자열2 - 자가진단1 ~ 11 (0) | 2023.10.04 |
---|---|
[자바] 정올 182 ~ 188 : 문자열1 - 형성평가1 ~ 7 (0) | 2023.10.04 |
[자바] 정올 231 ~ 236 : 함수3 - 형성평가1~6 (0) | 2023.10.03 |
[자바] 정올 587 ~ 592 : 함수3 - 자가진단1~6 (1) | 2023.10.03 |
[자바] 정올 175 ~ 181 : 함수2 - 형성평가1~7 (0) | 2023.10.03 |