https://www.acmicpc.net/problem/10818
package baekjoon;
import java.util.Scanner;
import java.util.Arrays;
public class B10818 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int a = in.nextInt();
int[] Array = new int[a];
for(int i=0; i<a; i++) {
Array[i] = in.nextInt();
}
Arrays.sort(Array); //오름차순으로 정렬
System.out.println(Array[0] + " " + Array[a-1]);
}
}
https://www.acmicpc.net/problem/4344
package baekjoon;
import java.util.Scanner;
public class B4344 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int c = in.nextInt();
int[] number = new int[c];
for(int i=0; i<c; i++) {
int x = in.nextInt();
int[] grade = new int[x];
double sum = 0;
double avg;
double count = 0;
for(int j=0; j<x; j++) {
grade[j] = in.nextInt();
sum += grade[j];
}
avg = (sum/(double)x);
for(int k=0; k<x; k++) {
if(grade[k] > avg) {
count++;
}
}
System.out.printf("%.3f%%\n",(count/x)*100);
//%0.3f" 소수점 3가지까지 반올림 / %출력하려면 %하나 더 붙여야됨
}
}
}
https://www.acmicpc.net/problem/8958
package baekjoon;
import java.util.Scanner;
public class B8958 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int c = in.nextInt();
in.nextLine();
for(int i = 0; i < c; i++) {
int sum = 0;
int k = 0;
String ox = in.nextLine();
for(int j=0; j<ox.length(); j++) {
if(ox.charAt(j) == 'O') {
k += 1;
}
else {
k = 0;
}
sum += k;
}
System.out.println(sum);
}
}
}
https://www.acmicpc.net/problem/3052
package baekjoon;
import java.util.*;
public class B3052 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int count = 10;
int k;
List<Integer> numList = new ArrayList<>();
for(int i=0; i<10; i++) {
int num = in.nextInt();
k = num%42;
numList.add(k);
}
Set<Integer> numSet = new HashSet<>(numList);
//set - 중복을 허용하지 않는 자료구조
System.out.println(numSet.size());
}
}
https://www.acmicpc.net/problem/15596
package baekjoon;
public class B15596 {
long sum(int[] a) {
long ans = 0;
for(int i=0; i<a.length; i++) {
ans += a[i];
}
return ans;
}
}
'Java-Study' 카테고리의 다른 글
Java Study : 5주차 - 백준 문제풀이 (0) | 2022.12.02 |
---|---|
Java Study : 5주차 정리 - 추상 클래스 (1) | 2022.12.02 |
Java Study : 4주차 정리 - 배열과 ArrayList, 상속과 다형성 (0) | 2022.11.26 |
Java Study : 3주차 - 문제 풀이 (1) | 2022.11.19 |
Java Study : 3주차 정리 (0) | 2022.11.18 |