목록백준 (36)
정리하고기록하자

백준 - 알고리즘 사칙연산 (10869) 문제 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a; int b; a = sc.nextInt(); 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); } } 두 정수 a,b 변수 선언 후 문제 : 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를..

백준 - 알고리즘 A/B (1008) 문제 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); double a,b; a = sc.nextDouble(); b = sc.nextDouble(); System.out.println(a/b); } } 변수 a,b 선언을 해준다. 정수 : 숫자 -2, -1 , 0 , 1 , 2 .... 소수점을 사용하지 않고 숫자를 표현한다. 실수 : 숫자 0.1 , 0.2, 0.3 ... 소수점을 사용하여 숫자를 표현한다. 백준 알고리즘 문제 예제 출력 에서 소수점으로 출력 되어야 하기 때문에 타입을 double 로 추가 ..

백준 - 알고리즘 AxB (10998) 문제 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a,b; a = sc.nextInt(); b = sc.nextInt(); System.out.println(a * b); } } 백준 알고리즘 (1000) , (1001) 번 문제와 비슷 하다. 정수 a,b 변수 선언 후 int a,b; a = sc.nextInt(); b = sc.nextInt(); 두 수에 곱을 해준다. System.out.println(a * b);

백준 알고리즘 A-B 문제 import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a = 3; int b = 2; a = sc.nextInt(); b = sc.nextInt(); System.out.println(a-b); } } 백준 알고리즘(1000) 문제에서 스캐너클래스 공부 후 문제를 읽어봤을때 두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오. (1000) 문제랑 비슷 한 문제라고 생각이 들었고 변수 a, b 에 3, 2 를 선언 한 뒤 int a = 3; int b = 2; a = sc.nextInt(); b ..

백준 알고리즘 A+B 문제 public class Main { public static void main(String[] args){ int a = 1; int b = 2; System.out.println(a+b); } } 처음 제출한 코드.. 문제에 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. 입력 받은 다음 A+B 를 출력 하는 프로그램을 작성 하시오 를 보고 다시 코드 수정. import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int a,b; a = sc.nextInt(); b = sc.nextInt(); Sy..

백준 알고리즘 고양이 문제 public class Main { public static void main(String[] args){ System.out.print("\ /\"); System.out.print(" ) ( ')"); System.out.print("( / )"); System.out.println(" \(__)|"); } } 처음 제출한 코드.. 에러코드 : illegal escape character escape (이스케이프 문자) : 문자열 내에서 특수한 기능을 수행하는 문자. \' : 홑따옴표 출력 \" : 쌍따옴표 출력 \n : 줄바꿈 \t : 탭문자 ( 일정한 간격 ) \\ : 역슬래시 출력 수정 후 코드 public class Main{ public static void mai..