알고리즘/BOJ

백준 4758번 Filling Out the Team

꾸준함. 2021. 5. 16. 20:09

문제 링크입니다: 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

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

 

#include <iostream>
using namespace std;
bool canBeWideReceiver(double speed, int weight, int strength)
{
return (speed <= 4.5 && weight >= 150 && strength >= 200);
}
bool canBeLineman(double speed, int weight, int strength)
{
return (speed <= 6.0 && weight >= 300 && strength >= 500);
}
bool canBeQuarterback(double speed, int weight, int strength)
{
return (speed <= 5.0 && weight >= 200 && strength >= 300);
}
int main(void)
{
ios_base::sync_with_stdio(0);
cin.tie(0);
while (1)
{
double speed;
int weight, strength;
cin >> speed >> weight >> strength;
if (speed == 0.00 && weight == 0 && strength == 0)
{
break;
}
int cnt = 0;
if (canBeWideReceiver(speed, weight, strength))
{
cnt++;
cout << "Wide Receiver ";
}
if (canBeLineman(speed, weight, strength))
{
cnt++;
cout << "Lineman ";
}
if (canBeQuarterback(speed, weight, strength))
{
cnt++;
cout << "Quarterback ";
}
if (cnt == 0)
{
cout << "No positions";
}
cout << "\n";
}
return 0;
}
view raw .cpp hosted with ❤ by GitHub

 

개발환경:Visual Studio 2017

 

지적, 조언, 질문 환영입니다! 댓글 남겨주세요~

반응형

'알고리즘 > BOJ' 카테고리의 다른 글

백준 4880번 다음수  (0) 2021.05.16
백준 4766번 일반 화학 실험  (0) 2021.05.16
백준 4714번 Lunacy  (0) 2021.05.16
백준 4690번 완전 세제곱  (0) 2021.05.16
백준 4655번 Hangover  (0) 2021.05.16