using namespace std;
int x[30][30],n,m,i,j,s=0;
void citire()
{
cout<<"n=";cin>>n;
for(i=1;i<=n;i++)
for(j=1;j<=n;j++)
{cout<<"x["<<i<<"]["<<j<<"]=";
cin>>x[i][j];
}
}
void afisare()
{
for( i=1;i<=n;i++)
{
for( j=1;j<=n;j++)
cout<<x[i][j]<<" ";
cout<<"\n";
}
}
void suma()
{
for (int i=1;i<=n;i++)
for (int j=1;j<=n;j++)
s=s+x[i][j];
cout<<"suma elementelor din matrice="<<s<<endl;
}
int main()
{cout<<"se citeste matricea: "<<endl;
citire();
cout<<"matricea este\n";
afisare();
suma();
return 0;
}
Niciun comentariu:
Trimiteți un comentariu