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";
	}
}

[결과 화면]