here is my code:

``````#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int A[10][10],m,n,x,y,sum=0;
// Ndertojme nje Matrice A
cout << "Ju lutemi vendosni numrin e rreshtave dhe te shtyllave per matricen A : \n";
cin>>n>>m;
cout << "Vendosni elementet e matrices A duke perdorur hapesine pas cdo elementi dhe enter per te kaluar tek rreshti tieter : \n";
for(x=1;x<n+1;++x)
for(y=1;y<m+1;++y)
cin>>A[x][y];
//Shuma e cdo rreshti
for(x=1;x<n+1;++x)
{
A[x][m+1]=0;
for(y=1;y<m+1;++y)
A[x][m+1]=A[x][m+1]+A[x][y];
}
//Shuma e cdo kolone
for(y=1;y<m+1;++y)
{
A[n+1][y]=0;
for(x=1;x<n+1;++x)
A[n+1][y]+=A[x][y];
}
cout << "\nMatrica A dhe shuma e rreshtave(kolona fundit)" << " Shuma kolonave (rreshti fundit) : \n";
for(x=1;x<n+1;++x)
{
for(y=1;y<m+2;++y)
cout << A[x][y] << "     ";
cout << "\n";
}
//Printo shumen e cdo rreshti
x=n+1;
for(y=1;y<m+1;++y)
cout << A[x][y] << "     ";
cout << "\n";
if(m==n)
{
for(x=1;x<m+1;x++)
for(y=1;y<n+1;y++)
if(x==y)
sum+=A[x][y];
else
if(y==m-(x+1))
sum+=A[x][y];
}
cout << "Shuma e elementeve te diagonales eshte : " << sum << endl;
getch();

return 0;
}``````

now i need to find the max of the last printed row
and print it

Your code is not readable. No indentation, not a comment in English....
If you re-post it after slight modification, then I'll can surely help you out.

``````#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int A[10][10],m,n,x,y,sum=0;
// Buil Matrix A
cout << "Please enter the number of rows and colum for matrix a : \n";
cin>>n>>m;
cout << "Enter the elemets of matrix a : \n";
for(x=1;x<n+1;++x)
for(y=1;y<m+1;++y)
cin>>A[x][y];
//Sum of rows
for(x=1;x<n+1;++x)
{
A[x][m+1]=0;
for(y=1;y<m+1;++y)
A[x][m+1]=A[x][m+1]+A[x][y];
}
//Sum of colums
for(y=1;y<m+1;++y)
{
A[n+1][y]=0;
for(x=1;x<n+1;++x)
A[n+1][y]+=A[x][y];
}
cout << "\nMatrix a and sum of  rows(last colum)" << " sum of colums (last row) : \n";
for(x=1;x<n+1;++x)
{
for(y=1;y<m+2;++y)
cout << A[x][y] << "     ";
cout << "\n";
}
//Print sum of each row
x=n+1;
for(y=1;y<m+1;++y)
cout << A[x][y] << "     ";
cout << "\n";
if(m==n)
{
for(x=1;x<m+1;x++)
for(y=1;y<n+1;y++)
if(x==y)
sum+=A[x][y];
else
if(y==m-(x+1))
sum+=A[x][y];
}
cout << "Sum of diagonal elements is : " << sum << endl;
getch();

return 0;
}``````

here is the code whith coment in english.
what i need is to return a print message(cout) whith the values of max values of the sum of culoms and a message whith the max values of the sum of row.
for exp:
the max value for the sum of colums for matrix A is:....
the max values for the sum of rows for matrix A is:....

``````#include <iostream.h>
#include <conio.h>
int main()
{
clrscr();
int A[10][10],m,n,x,y,sum=0;
int temp,lar_sum_row,lar_sum_col;
// Build Matrix A
cout << "Please enter the number of rows and colum for matrix a : \n";
cin>>n>>m;
cout << "Enter the elements of matrix a : \n";
for(x=0;x<n;x++)
for(y=0;y<m;y++)
cin>>A[x][y];
//Sum of rows
for(x=0;x<n;x++)
{
A[x][m]=0;
for(y=0;y<m;y++)
A[x][m]+=A[x][y];
}
//Sum of columns
for(y=0;y<m;y++)
{
A[n][y]=0;
for(x=0;x<n;x++)
A[n][y]+=A[x][y];
}
cout << "\n Matrix a and sum of  rows(last colum)" << " sum of columns (last row) : \n";
for(x=0;x<n+1;x++)
{
for(y=0;y<m+1;y++)
cout << A[x][y] << "     ";
cout << "\n";
}
//Print sum of each row
x=n;
temp=0;
for(y=0;y<m;y++)
{
cout << A[x][y] << "     ";
if(A[x][y]>temp);
temp=A[x][y];
}
cout << "\n";
lar_sum_row=temp;
temp=0;
y=m;
for(x=0;x<n;x++)
{
cout << A[x][y] << "     ";
if(A[x][y]>temp);
temp=A[x][y];
}
cout << "\n";
lar_sum_col=temp;

if(m==n)
{
for(x=1;x<m+1;x++)
for(y=1;y<n+1;y++)
if(x==y)
sum+=A[x][y];
else
if(y==m-(x+1))
sum+=A[x][y];
}
cout << "Sum of diagonal elements is : " << sum << endl;
cout<<"the max value for the sum of colums for matrix A is:-"<<lar_sum_col<<endl;
cout<<"the max value for the sum of rows for matrix A is:-"<<lar_sum_row<<endl;
getch();

return 0;
}``````

Probably it'll give you desired result. Not checked yet, but I''ll do that later also.

``````#include <iostream.h>
#include <conio.h>

int main()
{

int A[10][10],m,n,x,y,sum=0,max;
// Ndertojme nje Matrice A
cout << "Ju lutemi vendosni numrin e rreshtave dhe te shtyllave per matricen A : \n";
cin>>n>>m;
cout << "Vendosni elementet e matrices A duke perdorur hapesine pas cdo elementi dhe enter per te kaluar tek rreshti tieter : \n";
for(x=1;x<n+1;++x) for(y=1;y<m+1;++y) cin>>A[x][y];
//Shuma e cdo rreshti
for(x=1;x<n+1;++x)
{
A[x][m+1]=0;
for(y=1;y<m+1;++y) A[x][m+1]=A[x][m+1]+A[x][y];
}
//Shuma e cdo kolone
for(y=1;y<m+1;++y)
{
A[n+1][y]=0;
for(x=1;x<n+1;++x) A[n+1][y]+=A[x][y];
}
cout << "\nMatrica A, shuma e rreshtave(kolona e fundit)" << " Shuma kolonave (rreshti fundit): \n";
for(x=1;x<n+1;++x)
{
for(y=1;y<m+2;++y) cout << A[x][y] << "     ";
cout << "\n";
}
//Printo shumen e cdo rreshti
x=n+1;
for(y=1;y<m+1;++y)
cout << A[x][y] << "     ";
cout << "\n";
cout<<"\nMaximumi i shumave te rreshtave: ";
//maximumi i shumave te rreshtave
max=A[1][m+1];
for (x=2; x<=n; x++) if (A[x][m+1]>max) max=A[x][m+1];
cout<<max;
cout<<"\nMaximumi i shumave te kolonave: ";
max=A[n+1][1];
for (y=2; y<=m; y++) if (A[n+1][y]>max) max=A[n+1][y];
cout<<max<<endl;
if(m==n)
{
for(x=1;x<m+1;x++)
for(y=1;y<n+1;y++)
if(x==y) sum+=A[x][y];
else if(y==m-(x+1)) sum+=A[x][y];
}
cout << "Shuma e elementeve te diagonales eshte : " << sum << endl;

getch();

return 0;
}``````

ok i find the error.error wan in tha matrix in the declarain of the matrix the last row of the matrix was not a vector now is a vector so can i find the max values

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.