728x90
반응형
SMALL
형성평가1 : 175
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
Integer[] arr = new Integer[n];
for(int i = 0;i<arr.length;i++) arr[i] = sc.nextInt();
sort_pr(arr);
}
public static void sort_pr(Integer[] arr){
Arrays.sort(arr, Collections.reverseOrder());
for(int i = 0;i<arr.length;i++) System.out.print(arr[i] + " ");
}
}
형성평가2 : 176
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double a = sc.nextDouble(), b = sc.nextDouble();
count_int(a, b);
}
public static void count_int(double a, double b){
int count =0;
int max = (int)Math.sqrt(a > b ? a:b);
int min = (int)Math.ceil(Math.sqrt(a < b ? a :b));
for(double i = min; i <= max; i++){
count++;
}
System.out.println(count);
}
}
형성평가3 : 177
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[5];
for(int i = 0; i < arr.length; i++) arr[i] = sc.nextInt();
addAll(arr);
}
public static void addAll(int[] arr){
int sum = 0;
for(int i = 0; i < arr.length; i++) sum += Math.abs(arr[i]);
System.out.println(sum);
}
}
형성평가4 : 178
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
solution(n);
}
public static void solution(int a){
System.out.println((int)Math.pow(2, a));
}
}
형성평가5 : 179
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double[] arr = new double[3];
for(int i = 0; i < arr.length; i++)arr[i] = sc.nextDouble();
solution(arr);
}
public static void solution(double[] arr){
double sum = 0.0;
int sum_i = 0;
for(int i = 0; i < arr.length; i++){
sum += arr[i];
sum_i += (int)Math.round(arr[i]);
}
System.out.println(Math.round(sum/arr.length));
System.out.println(Math.round((double)sum_i/arr.length));
}
}
형성평가6 : 180
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int[] arr = new int[7];
for(int i = 0; i < arr.length; i++) arr[i] = sc.nextInt();
bubble_sort(arr);
}
public static void bubble_sort(int[] arr){
for(int i = 0; i < 3;i++){
for(int j = 0; j < arr.length-1; j++){
if(arr[j]>arr[j+1]){
int temp = arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
}
for(int k=0;k<arr.length;k++){
System.out.print(arr[k] + " ");
}
}
}
형성평가7 : 181
import java.util.Scanner;
public class Main {
public static final double pi = 3.141592;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("radius : ");
double r = sc.nextDouble();
area(r);
}
public static void area(double r){
System.out.printf("area = %.3f", r*r*pi);
}
}
728x90
반응형
LIST
'프로그래밍 > 자바' 카테고리의 다른 글
[자바] 정올 231 ~ 236 : 함수3 - 형성평가1~6 (0) | 2023.10.03 |
---|---|
[자바] 정올 587 ~ 592 : 함수3 - 자가진단1~6 (1) | 2023.10.03 |
[자바] 정올 579 ~ 586 : 함수2 - 자가진단1~8 (0) | 2023.10.03 |
[자바] 정올 170 ~ 174 : 함수1 - 형성평가1 ~ 5 (0) | 2023.10.02 |
[자바] 정올 571 ~ 578 : 함수1 - 자가진단1 ~ 8 (1) | 2023.10.01 |