[BaekJoon] 2083번 - 럭비 클럽 [Java][C++]
[BaekJoon] 2083번 - 럭비 클럽 [Java][C++]
1. 문제 풀이
조건문을 활용해서 나이와 몸무게를 기준으로 분기 처리만 해주면 된다.
2. 코드
1. 풀이 [Java]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
StringTokenizer st;
while (true) {
st = new StringTokenizer(br.readLine());
String name = st.nextToken();
int age = Integer.parseInt(st.nextToken());
int weight = Integer.parseInt(st.nextToken());
if (name.equals("#") && age == 0 && weight == 0) break;
if (age > 17 || weight >= 80) {
sb.append(name).append(" Senior\n");
} else {
sb.append(name).append(" Junior\n");
}
}
System.out.println(sb);
}
}
2. 풀이 [C++]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
while (true) {
string name;
int age, weight;
cin >> name >> age >> weight;
if (name == "#" && age == 0 && weight == 0) break;
if (age > 17 || weight >= 80) {
cout << name << " Senior\n";
} else {
cout << name << " Junior\n";
}
}
}
This post is licensed under CC BY 4.0 by the author.