[구름LEVEL] 리그 경기 횟수 구하기 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 팀의 수 int num = sc.nextInt(); // 경기의 수 변수 int sum = 0; for(int i = 1; i 코딩테스트 2021.03.12
[구름LEVEL] 시험성적 평균과 등급 구하기 문제 풀이 import java.io.*; import java.util.*; import java.text.DecimalFormat; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); double kor = sc.nextInt(); double eng = sc.nextInt(); double math = sc.nextInt(); double avg = (kor+eng+math)/3.0; DecimalFormat df = new DecimalFormat("0.00"); String str = df.format(avg); System.out.print(str+" "); if(avg >= 90) .. 코딩테스트 2021.03.12
[구름LEVEL] 특정 문자 개수 구하기 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String str = sc.nextLine(); char a = sc.next().charAt(0); // 카운트 int count = 0; // 50자 이내 조건 if(str.length() > 50) { return; } for(int i = 0; i 코딩테스트 2021.03.12
[구름LEVEL] Substring 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 공백 포함을 위해 nextLine()을 작성 String str1 = sc.nextLine(); int a = sc.nextInt(); int b = sc.nextInt(); String str2 = str1.substring(a-1,b+2); System.out.print(str2); } } 구름 페이지에 나온 테스트 케이스에는 맞지만 정답이 아니라고 한다. 그 이유에 대해 다시 공부해서 풀어야 될 것 같다. 코딩테스트 2021.03.12
[구름LEVEL] 3의 배수 게임 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); for(int i = 1; i 코딩테스트 2021.03.12
[구름LEVEL] 윤년(Leap Year) 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int year = sc.nextInt(); if(year%4 == 0 && (year%100 != 0 || year%400 == 0)){ System.out.print("Leap Year"); } else { System.out.print("Not Leap Year"); } } } 코딩테스트 2021.03.12
[구름LEVEL] 거스름돈 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 물건 가격 int cost = sc.nextInt(); int change = 1000 - cost; // 차례대로 500,100,50,10원 int a = 0; int b = 0; int c = 0; int d = 0; a = change / 500; b = change % 500 / 100; c = change % 500 % 100 / 50; d = change % 500 % 100 % 50 / 10; System.out.print(a+" "+b+" "+c+.. 코딩테스트 2021.03.12
[구름LEVEL] Bubble sort 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 배열 길이 int length = sc.nextInt(); // 배열할 숫자 입력받기 int[] num = new int[length]; for(int i=0; i 코딩테스트 2021.03.12
[구름LEVEL] 삼각형의 넓이 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); // 밑변 double a = sc.nextInt(); // 높이 double b = sc.nextInt(); // 넓이 double c = (a*b) / 2; String str = String.format("%.1f", c); System.out.print(str); } } 코딩테스트 2021.03.12
[구름LEVEL] 공백 없애기 문제 풀이 import java.io.*; import java.util.*; class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); // nextLine() : 공백 포함 String str = sc.nextLine(); str = str.replaceAll(" ",""); System.out.print(str); } } 코딩테스트 2021.03.12