#include <iostream>
usingnamespace std;
constint ROWCAP = 100;
constint COLCAP = 100;
// Function Prototypes
int findNorm(int userMatrix[ROWCAP][COLCAP], int, int);
int main()
{
// Initialize Variables
int rows;
int cols;
// Initialize Matrix
int userMatrix[ROWCAP][COLCAP];
cout << "We will find the 1 Norm (Maximum Absolute Sum Norm) of your matrix.\n";
// Enter Amount of Rows
cout << "Please enter the amount of rows (MAX of 100).\n";
cout << "> ";
cin >> rows;
// Validate Amount of Rows
while (rows <= 0 || rows >= ROWCAP)
{
cout << "Please enter a row size that is between 0 and 100.\n";
cout << "> ";
cin >> rows;
}
// Enter Amount of Columns
cout << "Please enter the amount of columns (MAX of 100).\n";
cout << "> ";
cin >> cols;
// Validate Amount of Columns
while (cols <= 0 || cols >= COLCAP)
{
cout << "Please enter a row size that is between 0 and 100.\n";
cout << "> ";
cin >> cols;
}
// Enter Matrix Values
cout << "Enter your Matrix.\n";
for (int i = 0; i < rows; i++)
{
for (int j = 0; j < cols; j++)
{
cout << "> ";
cin >> userMatrix[i][j];
}
}
// Display the User Matrix
cout << "Your Matrix is:\n";
for (int k = 0; k < rows; k++)
{
for (int l = 0; l < cols; l++)
{
cout << userMatrix[k][l];
}
}
// Find and Display the 1 Norm
cout << "The Absolute Maximum Sum Norm is: " << findNorm(int userMatrix[ROWCAP][COLCAP], rows, cols) << ".\n";
return 0;
}
// 1 Norm Function
int findNorm(int userMatrix[ROWCAP][COLCAP], int rows, int cols)
{
int sum;
int largest;
int total[cols];
cout << "\nCalculating Absolute Maximum Column Sum...\n";
// Column Calculation
for (int m = 0; m < rows; m++)
{
for (int n = 0; n < cols; n++)
{
sum += userMatrix[m][n];
for (int o = 0; o < cols; o++)
{
sum = total[o];
}
}
}
largest = total[0];
for (int p = 1; p < cols; p++)
{
if (largest < total[p])
{
largest = total[p];
}
}
cout << "Done!\n";
return largest;
}
void printarray( int arg[], int length );
int main ()
{
int firstarray[] = {5, 10, 15};
printarray( firstarray, 3 );
// not: printarray( int firstarray[], 3 );
}