본문 바로가기

Algorithm/Implementation

(C++) - 백준(BOJ) 4758 : Filling Out the Team

반응형

https://www.acmicpc.net/problem/4758

 

4758번: Filling Out the Team

For each player, you will output one line listing the positions that player can play. A player can play a position if each of their attributes is greater or equal to the minimum for weight and strength, and less than or equal to the slowest speed. If a pla

www.acmicpc.net

간단한 구현문제였습니다.

📕 풀이방법

📔 입력 및 초기화

 1. while loop를 수행합니다. 2. 포지션을 지정받았는지 알기 위한 변수 hasPosition, 속도 speed, 무게 weight, 힘 strength를 지역변수로 선언합니다.

📔 정답출력

조건에 따라 출력합니다.


📕 Code

#include <bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        bool hasPosition = false;
        double speed, weight, strength;
        cin >> speed >> weight >> strength;
        if(!speed && !weight && !strength) break;
        if(speed <= 4.5 && weight >= 150 && strength >= 200) 
            hasPosition = true, cout << "Wide Receiver ";
        if(speed <= 6.0 && weight >= 300 && strength >= 500) 
            hasPosition = true, cout << "Lineman ";
        if(speed <= 5.0 && weight >= 200 && strength >= 300) 
            hasPosition = true, cout << "Quarterback ";
        if(!hasPosition) cout << "No positions";
        cout << '\n';
    }
}