0% found this document useful (0 votes)
14 views8 pages

Matric I

The document contains C++ code that defines functions to input and output a 2D array (matrix), and then perform calculations on the matrix elements including: summing rows and columns, calculating averages, finding the maximum value. It demonstrates how to iterate through a 2D array, access elements, and perform basic operations like summation and comparison.

Uploaded by

Gorun Bianca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views8 pages

Matric I

The document contains C++ code that defines functions to input and output a 2D array (matrix), and then perform calculations on the matrix elements including: summing rows and columns, calculating averages, finding the maximum value. It demonstrates how to iterate through a 2D array, access elements, and perform basic operations like summation and comparison.

Uploaded by

Gorun Bianca
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

https://onlinegdb.

com/5fpvywzjrB

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j,s=0;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

cout<<"suma elementelor pe linie: "<<endl;

for (i=0; i<n; i++)

{for (j=0; j<n; j++)

{s=s+a[i][j];}

cout<<"i="<<i<<' '<<"s= "<<s<<endl; s=0;}

cout<<"suma elementelor pe coloana: "<<endl;

for (j=0; j<n; j++)

{for (i=0; i<n; i++)

{s=s+a[i][j];}

cout<<"j="<<j<<' '<<"s= "<<s<<endl; s=0;}

cout<<"elementele de pe diag principala sunt: ";

for (i=0; i<n; i++)


cout<<a[i][i]<<' ';

cout<<"elementele de pe diag secundara sunt: ";

for (i=0; i<n; i++)

cout<<a[i][n-i-1]<<' ';

return 0;

}
https://onlinegdb.com/UCCjFb8AS

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j;

double med,s=0,z=0;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

for (i=0; i<n; i++)

for (j=0; j<n; j++)

if (a[i][j]%2==0) {s=s+a[i][j]; z++;}

med=s/z;

cout<<"media nr pare= "<<med;

return 0;

}
https://onlinegdb.com/cnFlX4Eib

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j;

double med,s=0;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

for (i=0; i<n; i++)

{for (j=0; j<n; j++)

{s=s+a[i][j];}

med=s/n;

cout<<"media pe linie i= "<<med<<endl; med=0; s=0;}

return 0;

}
https://onlinegdb.com/TvKItJ2Q0

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j;

double med,s=0;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

for (j=0; j<n; j++)

{for (i=0; i<n; i++)

{s=s+a[i][j];}

med=s/n;

cout<<"media pe coloana j= "<<med<<endl; med=0; s=0;}

return 0;

}
https://onlinegdb.com/9bbNq0o4m

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j,max=-32768;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

for (i=0; i<n; i++)

for (j=0; j<n; j++)

if(max<a[i][j]) max=a[i][j];

cout<<"maximul este: "<<max;

return 0;

}
https://onlinegdb.com/yz38l9O5Y

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j,max=-32768;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

for (i=0; i<n; i++)

{ for (j=0; j<n; j++)

if(max<a[i][j]) max=a[i][j];

cout<<"maximul pe linia i= "<<max<<endl; max=-32768;}

return 0;

}
https://onlinegdb.com/nFD3ZdXyB

#include <iostream>

using namespace std;

int main()

int a[100][100],n,i,j,max=-32768;

cout<<"introduceti n= ";

cin>>n;

for (i=0; i<n; i++)

for (j=0; j<n; j++)

{cout<<"a["<<i<<"]"<<"["<<j<<"]=";

cin>>a[i][j];}

cout<<"matricea:"<<endl<<endl;

for (i=0; i<n; i++)

{for (j=0;j<n;j++)

{cout<<a[i][j]<<' ';}

cout<<endl;}

for (j=0; j<n; j++)

{ for (i=0; i<n; i++)

if(max<a[i][j]) max=a[i][j];

cout<<"maximul pe coloana j= "<<max<<endl; max=-32768;}

return 0;

You might also like