๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

๐Ÿ“ ์•Œ๊ณ ๋ฆฌ์ฆ˜/Programmers

[C++/PGS] Lv.? : ์ƒํ˜ธ ํ‰๊ฐ€ (๋„ค์ด๋ฒ„ ๊ธฐ์ถœ)

 

๋„ค์ด๋ฒ„ ์ฝ”ํ…Œ๋Š” ์–ด๋–ค ์‹์œผ๋กœ ๋‚˜์˜ค๋Š”์ง€ ์ฐพ์•„๋ณด๋‹ค๊ฐ€ ๋ฐœ๊ฒฌํ•œ ๋ธ”๋กœ๊ทธ ๊ธ€์ด๋‹ค.

์™œ์ธ์ง€ ์ง€๊ธˆ์€ ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค์—์„œ ๋ฌธ์ œ๊ฐ€ ๋‚ด๋ ค๊ฐ„ ๊ฒƒ ๊ฐ™์€๋ฐ, ๋‚œ์ด๋„๊ฐ€ ๋‚ฎ์•„๋ณด์—ฌ์„œ ๊ทธ๋ƒฅ ํ•œ๋ฒˆ ํ’€์–ด๋ณด์•˜๋‹ค

 

https://drcode-devblog.tistory.com/262

 

[ํ”„๋กœ๊ทธ๋ž˜๋จธ์Šค/java] ์ƒํ˜ธ ํ‰๊ฐ€ - ๋„ค์ด๋ฒ„ ์ฝ”๋”ฉํ…Œ์ŠคํŠธ(์ฝ”ํ…Œ) ๊ธฐ์ถœ๋ฌธ์ œ

https://programmers.co.kr/learn/courses/30/lessons/83201 ์ฝ”๋”ฉํ…Œ์ŠคํŠธ ์—ฐ์Šต - 2์ฃผ์ฐจ [[100,90,98,88,65],[50,45,99,85,77],[47,88,95,80,67],[61,57,100,80,65],[24,90,94,75,65]] "FBABD" [[70,49,90],[68,50,38],[73,31,100]] "CFD" programmers.co.kr ์ƒํ˜ธ

drcode-devblog.tistory.com

 

๋‚˜์˜ ํ’€์ด

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
using namespace std;

int scores[11][11];

string solution(int t){
    string answer = "";
    for (int i = 0; i < t; ++i){ // ์ตœ๊ณ ์ , ์ฃ„์ €์  ์ฒ˜๋ฆฌ
        int maxs = *max_element(scores[i], scores[i] + t);
        int mins = *min_element(scores[i], scores[i] + t);
        if(scores[i][i] == maxs) scores[i][i]=-1;
        else if(scores[i][i] == mins) scores[i][i]=-1;
    }

    for (int i = 0; i < t; ++i){
        int sum = 0;
        int cnt = 0;
        for (int j = 0; j < t; ++j){
            if(scores[j][i]<0) continue;
            sum += scores[j][i];
            cnt++;
        }
        sum /= cnt;
        if(sum>=90) answer+="A";
        else if(sum>=80) answer+="B";
        else if(sum>=70) answer+="C";
        else if(sum>=50) answer+="D";
        else answer+="F";
    }
    return answer;
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int t;

    cin >> t;
    for (int i = 0; i < t; ++i){
        for (int j = 0; j < t; ++j){
            cin >> scores[i][j];
        }
    }

    cout << solution(t);
    
    return 0;
}