본문 바로가기

STORY174

Java - 백준 코딩테스트 1008번 [입출력과 사칙연산 - A/B] 1234567891011121314import java.util.Scanner; public class BintoA { public static void main(String[] args) { // 20210609 - 1008번 Scanner sc = new Scanner(System.in); double a = sc.nextDouble(); double b = sc.nextDouble(); System.out.println(a / b); } } Colored by Color Scriptercs 2021. 6. 24.
Java - 백준 코딩테스트 10430번 [입출력과 사칙연산 - 나머지] 12345678910111213141516171819import java.util.Scanner; public class Remainder { public static void main(String[] args) { //20210610 - 10430번 Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); int c = sc.nextInt(); System.out.println((a + b) % c); System.out.println(((a % c) + (b % c)) % c); System.out.println((a * b) % c); System.out.println(((a % c) * (b % c)) % c).. 2021. 6. 24.
Java - 백준 코딩테스트 2588번 [입출력과 사칙연산 - 곱셈] 123456789101112131415161718192021222324import java.util.Scanner; public class Multiplication { public static void main(String[] args) { // 20210610 - 2588번 Scanner sc = new Scanner(System.in); int a = sc.nextInt(); //세 자리 자연수 1 int b = sc.nextInt(); //세 자리 자연수 2 int[] arr = new int[3]; arr[0] = b % 10; //b의 1의 자리 arr[1] = (b % 100) / 10; //b의 10의 자리 arr[2] = b / 100; //b의 100의 자리 System.out.prin.. 2021. 6. 24.
Java - 백준 코딩테스트 1330번 [if문 - 두 수 비교하기] 123456789101112131415161718192021import java.util.Scanner; public class TwoNumsCompare { public static void main(String[] args) { // 20210610 - 1330번 Scanner sc = new Scanner(System.in); int a = sc.nextInt(); int b = sc.nextInt(); if (a > b) { System.out.println(">"); } else if (a 2021. 6. 24.
Java - 백준 코딩테스트 9498번 [if문 - 시험 성적] 12345678910111213141516171819202122232425262728293031import java.util.Scanner; public class TestScores { public static void main(String[] args) { // 20210611 - 9498번 Scanner sc = new Scanner(System.in); int score = sc.nextInt(); //while문으로 입력값 유효성 검사 while (score >= 0 && score = 90) { System.out.println("A"); break; } else if (score >= 80) { System.out.println("B"); break; } else if (score >= 70.. 2021. 6. 24.
Java - 백준 코딩테스트 2753번 [if문 - 윤년] 12345678910111213141516171819202122232425import java.util.Scanner; public class LeapYear { public static void main(String[] args) { // 20210611 - 2753번 //윤년이면 1, 아니면 0 출력 //윤년 : 연도가 4의 배수이면서 100의 배수가 아닐 때 또는 400배수일 때 //입력값 : 1보다 크거나 같고, 4000보다 작거나 같은 자연수 Scanner sc = new Scanner(System.in); int year = sc.nextInt(); int leapYear = 0; while (year >= 1 && year 2021. 6. 24.