본문 바로가기

Coding Test

(221)
[백준/자바] 10869 - 사칙연산 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(); System.out.println(A+B); System.out.println(A-B); System.out.println(A*B); System.out.println(A/B); System.out.println(A%B); sc.close(); } }
[백준/자바] 1008 - A/B import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double A = sc.nextDouble(); double B = sc.nextDouble(); System.out.println(A/B); sc.close(); } }
[백준/자바] 10998 - A×B 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(); System.out.println(a*b); sc.close(); } }
[백준/자바] 1001 - A-B 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(); System.out.println(A-B); sc.close(); } }
[백준/자바] 1000 - A+B 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(); System.out.println(A+B); sc.close(); } }
[백준/자바] 2557 - Hello World public class Main { public static void main(String[] args){ System.out.println("Hello World!"); } }
[프로그래머스/자바] 약수의 합('자바 입문' 강의 마지막 문제) class Solution { public int solution(int n) { int answer = 0; for(int i=1; i
[프로그래머스/자바] 삼각형의 완성조건(1) class Solution { public int solution(int[] sides) { int max = 0; int sum = 0; for(int i : sides){ if(maxmax) return 1; else return 2; } } import java.util.Arrays; class Solution { public int solution(int[] sides) { int answer = 0; Arrays.sort(sides); return sides[2] >= sides[0]+sides[1] ? 2 : 1; } } Arrays.sort 와 삼항 연산자를 이용한 풀이