#include <iostream>
#include <iomanip>
using namespace std;

	const int COLS = 3;
	const int ROWS = 4;
	int metalNo[ROWS][COLS];
	int row,col,country;
	int totalArr(int [][COLS],int);
	int big(int [ROWS][COLS]);
	int small(int [ROWS][COLS]);
	int gold(int [ROWS][COLS]);
	int bronze(int [ROWS][COLS],int);

int main()
{
	for (row=0;row<ROWS;row++)
	{
		for(col=0;col<COLS;col++)
		{
			if(col==0)
				cout << "Country "<<row+1<<" Gold:   ";
				else if(col==1)
				cout << "Country "<<row+1<<" Silver: ";
				else 
				cout << "Country "<<row+1<<" Bronze: ";
				cin>>metalNo[row][col];
		}
		cout<<endl;
	}
	cout << "Choose a country to find total number of medals: ";
	cin >> country;
	
		while(country<1||country>4)
	{
		cout<<"Wrong input. Please enter correct country."<<endl;
		cout << "Choose a country for total number of medals: ";
		cin >> country;
	}
	cout << "The total number of medals won by the selected country "<<country<<" is "
	<< totalArr(metalNo,country)<< endl;
	
	cout << "The largest number of medals won is "
	<< big(metalNo)<<endl;
	
	cout << "The smallest number of medals won is "
	<< small(metalNo)<<endl;
	
	cout << "The highest number of gold medal won is "
	<< gold(metalNo) <<endl;
	
	cout << "The total number of bronze medal won by the country is "
	<< bronze(metalNo,country)<<endl;
	
	return 0;
}

int totalArr(int array[][COLS],int number)
{
	int total=0;
	for(int col=0;col<COLS;col++)
		total=total+metalNo[number-1][col];
			
	return total;
}

int big(int metalNo[ROWS][COLS])
{
	int hold=metalNo[0][0];
	for(int row=0;row<ROWS;row++)
		for(int col=0;col<COLS;col++)
			if(metalNo[row][col]>hold)
				hold=metalNo[row][col];
	
	return hold;
}

int small(int metalNo[ROWS][COLS])
{
	int hold=metalNo[0][0];
	for(int row=0;row<ROWS;row++)
		for(int col=0;col<COLS;col++)
			if(metalNo[row][col]<hold)
				hold=metalNo[row][col];
	
	return hold;
}


int bronze(int metalNo[ROWS][COLS],int number)
{
	int medal=metalNo[number-1][2];
			
	return medal;
}

int gold(int metalNo[ROWS][COLS])
{
	int win=metalNo[0][0];
	for(int row=0;row<ROWS;row++)
		if(metalNo[row][0]>win)
			win=metalNo[row][0];
			
	return win;
}	

