본문 바로가기
프로그래머 ,백준, 유튜브, 문제

백준배열 1546 / 8958

by 리승우 2022. 8. 23.

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class _1546 {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
		
	int N = scan.nextInt();
	float sum = 0;
	float[] arr = new float[N];
		
		for(int i=0; i<N; i++) {
			arr[i] = scan.nextInt();
		}
			
		Arrays.sort(arr);
		float Max = arr[N-1];
		
		for(int j=0; j<N; j++) {
			sum += (arr[j]/Max*100)/N;
		}
		System.out.println(sum);
		
//		System.out.println(((double)((double)in/Max)*100)/3);

	}
}

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class _8958 {
	public static void main(String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] arr = new String[scan.nextInt()];

	for(int i=0; i<arr.length; i++) {
		arr[i] = scan.next();
	}
	
//	List<String> list = Arrays.asList(arr);
	// 배열 -> List로 변환
	
	for(int i=0; i<arr.length; i++) {
		int cnt = 0;
		int sum = 0;
		
		for(int j=0; j<arr[i].length(); j++) {
			if(arr[i].charAt(j) == 'O') {
				cnt++;
			} else {
				cnt = 0;
			}
			sum += cnt;
		}
		System.out.println(sum);
	}
	}
}

댓글