Notice
Recent Posts
Recent Comments
Link
«   2025/10   »
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 28 29 30 31
Archives
Today
Total
관리 메뉴

코딩로그

[백준/BOJ/C++] 9699번 RICE SACK 본문

YJ/C++

[백준/BOJ/C++] 9699번 RICE SACK

Team DAON 2021. 11. 2. 17:21

[문제]

Several sacks of rice need to be transported to five Orphanage Houses. The heaviest sack will go to Orphanage House Al-Ameen because it has the most number of orphanges. The lightest will be sent to Orphanage House Mutiara due to the small number of children staying there. Given a row of rice sacks, decide which sack goes to Al-Ameen?

[입력]

The first line is an integer that represent the number of case. The following lines have 5 integers indicating the weights of 5 rice sacks, each separated by a blank. No sack will have a weight of more than 100 unit.

[출력]

For each test case, the output contains a line in the format Case #x: followed by a sequence of integers, where x is the case number (starting from 1) and an integer that indicates the weight of a rice sack that will go to Al-Ameen.

[Source Code]

#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;


int main() {
	int num;
	cin >> num;
	int *arr = new int[num];

	for(int i = 0; i < num; i++){
		int max = 0;
		for(int j = 0; j < 5; j++){
			int input;
			cin >> input;
			if(input > max)
				max = input;
		}
		arr[i] = max;
	}

	for(int i = 0; i< num; i++){
		cout << "Case #" << i+1<<": "<<arr[i]<<"\n";
	}
}

[결과 화면]

'YJ > C++' 카테고리의 다른 글

[백준/BOJ/C++] 7581번 Cuboids  (0) 2021.11.02
[백준/BOJ/C++] 5751번 Head or Tail  (0) 2021.11.02
[백준/BOJ/C++] 13985번 Equality  (0) 2021.11.02
[백준/BOJ/C++] 16018번 Occupy parking  (0) 2021.11.02
[백준/BOJ/C++] 14782번 Bedtime Reading, I  (0) 2021.11.02