Algorithm(23.2.2)

2023. 2. 2. 18:45·algorithm

백준 1546

 

 

코드

import java.util.Arrays;
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        double score[] = new double[n];
        double M;
        double sum = 0;

        for (int i = 0; i < score.length; i++) {
            score[i] = sc.nextDouble();
        } //값 넣기
        Arrays.sort(score);

        for(int i=0; i<score.length; i++){
            sum += score[i]/score[score.length-1]*100;
        }
        double Average = sum/score.length;

        System.out.println(Average);
    }
}

문제를 조금더 꼼꼼히 볼 필요가 있었다. 망친 과목의 점수만 변경하여 평균을 내는줄 알았는데 전체 과목을 다 바꿔지기 해야 하더라,,

한 과목도 아니고 모든 과목을 조작하다니 세준이가 간땡이가 부은거같다.

 

 

배열 크기와 인덱스 헷갈리지 않게 한번더 신경쓰는 연습필요. 

저작자표시 (새창열림)

'algorithm' 카테고리의 다른 글

Algorithm(23.1.29)  (0) 2023.01.31
Algorithm(23.1.23)  (0) 2023.01.23
Algorithm(23.1.19)  (0) 2023.01.19
Algorithm (23.1.5)  (1) 2023.01.07
'algorithm' 카테고리의 다른 글
  • Algorithm(23.1.29)
  • Algorithm(23.1.23)
  • Algorithm(23.1.19)
  • Algorithm (23.1.5)
noeyh
noeyh
기록하고 성장하는 개발자, 최유현 입니다. github : https://github.com/Choiyuhyeon
    티스토리 홈 로그아웃
  • noeyh
    CreateU
    noeyh
  • 전체
    오늘
    어제
  • 글쓰기 관리
    GitHub
    Notion
    • 분류 전체보기 (31)
      • web (22)
        • html (5)
        • css (4)
        • js (5)
        • react (6)
        • next (1)
      • server (0)
      • linux (0)
      • figma (0)
      • ml (0)
      • algorithm (5)
      • git (1)
      • 미니프로젝트 (0)
      • 프로젝트 (0)
      • 정보 (0)
      • 일상 (0)
      • memo (1)
  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 링크

  • 공지사항

  • 인기 글

  • hELLO· Designed By정상우.v4.10.6
noeyh
Algorithm(23.2.2)
상단으로

티스토리툴바