
Patrick B. answered 05/27/21
Math and computer tutor/teacher
using namespace std;
#include <iostream>
void Input(int A[][10],int* n)
{
int x;
int N=11;
while (N>10 || N<0)
{
cout << "How many rows/columns ??? :>";
cin >> N;
}
*n = N;
for (int rowLoop=0; rowLoop<N; rowLoop++)
{
for (int columnLoop=0; columnLoop<N; columnLoop++)
{
x=-1;
while (x!=0 && x!=1)
{
cout << " Cell " << rowLoop << " " << columnLoop << " :>";
cin >> x;
}
A[rowLoop][columnLoop]=x;
}
}
}
int Count(int A[][10],int n)
{
int rowTotal=0;
int maxRowTotal=0;
int rowNumOfMax=-1;
for (int iLoop=0; iLoop<n; iLoop++)
{
rowTotal=0;
for (int jLoop=0; jLoop<n; jLoop++)
{
rowTotal += A[iLoop][jLoop];
}
if (rowTotal>maxRowTotal)
{
maxRowTotal = rowTotal;
rowNumOfMax = iLoop;
}
}
return(rowNumOfMax);
}
int main()
{
int A[10][10];
int n;
Input(A,&n);
int iMaxRow = Count(A,n);
cout << iMaxRow << endl;
}