[BaekJoon] 5522번 - 카드 게임 [Java][C++]
[BaekJoon] 5522번 - 카드 게임 [Java][C++]
1. 문제 풀이
주어진 5회의 총점만 구하면 되는 간단한 문제다.
2. 코드
1. 풀이 [Java]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int sum = 0;
for (int i = 0; i < 5; i++) {
sum += Integer.parseInt(br.readLine());
}
System.out.println(sum);
}
}
2. 풀이 [C++]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int sum = 0;
for (int i = 0; i < 5; i++) {
int x;
cin >> x;
sum += x;
}
cout << sum;
}
This post is licensed under CC BY 4.0 by the author.