728x90
반응형
SMALL
자가진단1
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
pr(n);
}
public static void pr(int n){
System.out.println("~!@#$^&*()_+|\n".repeat(n));
}
}
자가진단2
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
won(n);
}
public static void won(int n){
double a = n*n*3.14;
System.out.printf("%.2f",a);
}
}
자가진단3
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
pr(n);
}
public static void pr(int n){
int a = 1;
for(int i = 0; i < n; i++){
for(int j = 0; j < n; j++){
System.out.print(a + " ");
a++;
}
System.out.println();
}
}
}
자가진단4
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] arr = sc.nextLine().trim().split("\\s+");
int[] arr_int = new int[3];
for(int i = 0; i < 3; i++) arr_int[i] = Integer.parseInt(arr[i]);
findMax(arr_int);
}
public static void findMax(int[] arr){
Arrays.sort(arr);
System.out.println(arr[arr.length-1]);
}
}
자가진단5
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
power_two(a,b);
}
public static void power_two(int a, int b){
System.out.printf("%d",(int)Math.pow(a,b));
}
}
자가진단6
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String str = sc.nextLine().trim();
cal(str);
}
public static void cal(String str){
String[] arr = str.split("\\s+");
int answer;
if(arr[1].equals("+")) {
answer = Integer.parseInt(arr[0]) + Integer.parseInt(arr[2]);
}
else if(arr[1].equals("-")){
answer = Integer.parseInt(arr[0]) - Integer.parseInt(arr[2]);
}
else if(arr[1].equals("/")) {
answer = Integer.parseInt(arr[0]) / Integer.parseInt(arr[2]);
}
else if(arr[1].equals("*")) {
answer = Integer.parseInt(arr[0]) * Integer.parseInt(arr[2]);
}else answer = 0;
System.out.println(str + " = " +answer);
}
}
자가진단7
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
int max =find_max(a, b);
int min = find_min(a, b);
if(a == max) System.out.printf("%d %d", max/2, min*2);
else System.out.printf("%d %d", min*2,max/2);
}
public static int find_max(int a, int b){
return a > b ? a : b;
}
public static int find_min(int a, int b){
return a < b ? a : b;
}
}
자가진단8
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt(), b = sc.nextInt();
if(a < b) GUGUDAN(a, b);
else GUGUDAN(b, a);
}
public static void GUGUDAN(int a, int b){
for(int i = a; i <=b; i++){
System.out.println("== "+i+"dan ==");
for(int j = 1; j < 10; j++){
System.out.printf("%d *%2d =%3d",i,j,i*j);
System.out.println();
}
System.out.println();
}
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 579 ~ 586 : 함수2 - 자가진단1~8 (0) | 2023.10.03 |
---|---|
[자바] 정올 170 ~ 174 : 함수1 - 형성평가1 ~ 5 (0) | 2023.10.02 |
[자바] 정올 160 ~ 169 : 배열2 - 형성평가1 ~ 10 (0) | 2023.09.30 |
[자바] 정올 564 ~ 570 : 배열2 - 자가진단1 ~ 7 (0) | 2023.09.30 |
[자바] 정올 150 ~ 159 : 배열1 - 형성평가 1 ~ 10 (0) | 2023.09.30 |