본문 바로가기

분류 전체보기71

[백준 10869번 ː 자바(JAVA)] 사칙연산 두 자연수 A와 B가 주어진다. 이때, A+B, A-B, A*B, A/B(몫), A%B(나머지)를 출력하는 프로그램을 작성하시오. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 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(); sc.close(); System.out.println(a+b); System.out.println(a-b); System.out.println(a*b); System.out.println((int)a.. 2020. 4. 14.
[백준 1008번 ː 자바(JAVA)] A/B 두 정수 A와 B를 입력받은 다음, A/B를 출력하는 프로그램을 작성하시오. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 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(); sc.close(); System.out.println((double)a/b); } } * double을 넣음으로써 소수점이 출력될 수 있게 해 줍니다. 2020. 4. 14.
[백준 10998번 ː 자바(JAVA)] A x B 두 정수 A와 B를 입력받은 다음, A×B를 출력하는 프로그램을 작성하시오. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 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(); sc.close(); System.out.println(a*b); } } 2020. 4. 14.
[백준 10718번 ː 자바(JAVA)] We love kriii ACM-ICPC 인터넷 예선, Regional, 그리고 World Finals까지 이미 2회씩 진출해버린 kriii는 미련을 버리지 못하고 왠지 모르게 올 해에도 파주 World Finals 준비 캠프에 참여했다. 대회를 뜰 줄 모르는 지박령 kriii를 위해서 격려의 문구를 출력해주자. 두 줄에 걸쳐 "강한친구 대한육군"을 한 줄에 한 번씩 출력한다. 1 2 3 4 5 6 7 8 9 10 public class Main { public static void main(String[] args) { System.out.println("강한친구 대한육군"); System.out.println("강한친구 대한육군"); } } 1 2 3 4 5 6 7 8 9 10 public class Main { public.. 2020. 4. 14.
[백준 2557번 ː 자바(JAVA)] Hello World Hello World!를 출력하시오. 1 2 3 4 5 6 7 8 9 public class Main { public static void main(String[] args) { System.out.println("Hello World!"); } } 2020. 4. 14.
[백준 1001번 ː 자바(JAVA)] A-B 두 정수 A와 B를 입력받은 다음, A-B를 출력하는 프로그램을 작성하시오. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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(); sc.close(); System.out.println(a-b); } } * Scanner 를 사용하여 입력 받기 (Scanner 는 java.util 에서 제공됨) * sc.close(); 를 통해 메모리 사용량 줄이기 이전 1000번 문제에서 기호 하나만 바꾸면 되는.. 2020. 4. 13.
[백준 1000번 ː 자바(JAVA)] A+B 두 정수 A와 B를 입력받은 다음, A+B를 출력하는 프로그램을 작성하시오. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 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(); sc.close(); System.out.println(a+b); } } * Scanner 를 사용하여 입력 받기 (Scanner 는 java.util 에서 제공됨) * sc.close(); 를 통해 메모리 사용량 줄이기 클래스 이름을 계속 다른 이름으로 했다가 런타임 .. 2020. 4. 13.
[JAVA ː 자바] 구구단 가로/세로 출력하기 2단부터 9단까지 구구단을 출력하는 예제. 구구단을 출력하기 위해서는 이중 for문을 이용하면 됩니다. 1단부터 출력하실 분들은 3번째 줄 i=2를 i=1로 변경하시면 됩니다. 우선, 세로로 출력되는 구구단의 소스코드입니다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 public class Mygugu { public static void main(String[] args) { for(int i=2; i 2020. 4. 13.