728x90
2083번: 럭비 클럽
입력 받은 각 회원에 대해 이름과 분류를 출력한다. 성인부 회원이면 'Senior', 청소년부 회원이면 'Junior'를 출력한다.
www.acmicpc.net
문제 풀이
입력값을 받아, 조건에 맞게 출력하는 문제이다. 조건은 다음과 같다
- 나이가 17세 보다 많으면, 성인부 회원이다.
- 몸무게가 80kg 이상이면, 성인부 회원이다.
- 두 조건 중 하나라도 충족하지 않는다면, 청소년부 회원이다.
- 입력값이 # 0 0이면, 입력 처리를 종료한다.
조건에 맞게 조건문을 작성하면 된다.
정답 코드
C++
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0)
#define ll long long
int main() {
fast;
string n;
int age, weight;
while (1) {
cin >> n >> age >> weight;
if (n == "#" && age == 0 && weight == 0) break;
if (age > 17 || weight >= 80) cout << n << " Senior\n";
else cout << n << " Junior\n";
}
return 0;
}
python
while True :
name, age, weight = input().split()
age, weight = int(age), int(weight)
if name == "#" and age == 0 and weight == 0 : break
if age > 17 or weight >= 80 : print(name, "Senior")
else : print(name, "Junior")
728x90
'Algorithm > PS' 카테고리의 다른 글
[BOJ/백준] 3765 - Celebrity jeopardy [C++/python] (0) | 2023.03.01 |
---|---|
[C++, python] BOJ, 백준 3733 - Shares (0) | 2023.02.28 |
[C++, python] 프로그래머스 - 숫자의 표현 (0) | 2023.02.27 |
[C++, python] 프로그래머스 - 최솟값 만들기 (0) | 2023.02.27 |
[C++, python] 프로그래머스 - 둘만의 암호 (0) | 2023.02.26 |