#include <iostream>
int largestNumber(int nVariables, int numbers[])
{
int largest = numbers[0];
for (int i = 0; i <= nVariables; i++) {
largest = (largest<numbers[i]?numbers[i]:largest);
}
return largest;
}
int main()
{
int nOfVariables;
std::cout << "Input number of variables: ";
std::cin >> nOfVariables;
int variables[nOfVariables - 1];
for (int i = 0; i < nOfVariables; i++) {
std::cout << "Enter Variable #" << i + 1 << ": ";
std::cin >> variables[i];
}
std::cout << std::endl;
std::cout << std::endl << largestNumber(nOfVariables, variables) << std::endl;
}
#include<iostream>
using namespace std;
void ro(int matrix1[][4]);
int main()
{
int matrix1[6][4] = {
{42, 32, 42, 52 },
{43, 34, 23, 53 },
{23, 54, 24, 3 },
{3, 5, 6, 55 },
{34, 6, 45, 56 },
{45, 56, 56, 57 }
};
ro(matrix1);
return 0;
}
void ro(int matrix1[][4])
{
for (int MainRowIndex = 0; MainRowIndex < 6; MainRowIndex++)
{
int ColumnIndex = 0, MainRowIndexTeller = 0, ColoumsIndexTeller = 0;
for (ColumnIndex = 0; ColumnIndex < 4; ColumnIndex++)
{
int max = matrix1[MainRowIndex][0];
if (matrix1[MainRowIndex][ColumnIndex] > max)
{
matrix1[MainRowIndex][0] = matrix1[MainRowIndex][ColumnIndex];
MainRowIndexTeller = MainRowIndex; ColoumsIndexTeller = ColumnIndex;
}
}
if (MainRowIndex == 0)
{
cout << "In Ist Row:: Maximum Value is " << matrix1[MainRowIndex][0] << " Which Row&Colum No " << (1 + MainRowIndexTeller) << (1 + ColoumsIndexTeller) << "
";
}
if (MainRowIndex == 1)
{
cout << "In 2nd Row:: Maximum Value is " << matrix1[MainRowIndex][0] << " Which Row&Colum No " << (1 + MainRowIndexTeller) << (1 + ColoumsIndexTeller) << "
";
}
else if (MainRowIndex == 2)
{
cout << "In 3rd Row:: Maximum Value is " << matrix1[MainRowIndex][0] << " Which Row&Colum No " << (1 + MainRowIndexTeller) << (1 + ColoumsIndexTeller) << "
";
}
else if (MainRowIndex > 2)
{
cout << "In " << (1 + MainRowIndex) << "th Row:: Maximum Value is " << matrix1[MainRowIndex][0] << " Which Row & Colum No " << (1 + MainRowIndexTeller) << (1 + ColoumsIndexTeller) << "
";
}
}
}