Va rog am nevoie urgent
Răspunsuri la întrebare
Răspuns:
2)
#include<iostream>
using namespace std;
int main(){
int a[20][20],i,j,n,m;
cout<< "Introduceti numarul de randuri:";
cin >> n ;
cout << "Introduceti numarul de coloane:";
cin >> m;
for ( i = 0 ; i < n ; i++)
for (j = 0 ; j<m ; j++){
cout << "A[" << i << "][" << j << "]=";
cin >> a[i][j];
}
cout << "Matricea este : " << endl;
for ( i =0 ; i<n ;i++){
for(j=0;j<m;j++)
cout << a[i][j] << " " ;
cout << endl;
}
int s = 0;
for (i=0;i<n;i++)
for (j=0;j<m;j++){
if (a[i][j] % 2 == 0){
s = s + a[i][j];
}
}
cout << "Suma elementelor pare:" << s ;
return 0 ;
}
4
)#include<iostream>
using namespace std;
int main(){
int a[20][20],i,j,n,m;
cout<< "Introduceti numarul de randuri:";
cin >> n ;
cout << "Introduceti numarul de coloane:";
cin >> m;
for ( i = 1 ; i <= n ; i++)
for (j = 1 ; j<=m ; j++){
cout << "A[" << i << "][" << j << "]=";
cin >> a[i][j];
}
cout << "Matricea este : " << endl;
for ( i =1 ; i<=n ;i++){
for(j=1;j<=m;j++)
cout << a[i][j] << " " ;
cout << endl;
}
for (i=1;i<=n;i++)
{
int p = 1;
for (j=1;j<=n;j++)
if (a[i][j] % 2 != 0)
p = p * a[i][j];
cout << "Produsul elemetelor impare de pe linia " << i << " este : " << p << endl;
}
return 0 ;
}
5)
#include<iostream>
using namespace std;
int main(){
int a[20][20],i,j,n,m;
cout<< "Introduceti numarul de randuri:";
cin >> n ;
cout << "Introduceti numarul de coloane:";
cin >> m;
for ( i = 1 ; i <= n ; i++)
for (j = 1 ; j<=m ; j++){
cout << "A[" << i << "][" << j << "]=";
cin >> a[i][j];
}
cout << "Matricea este : " << endl;
for ( i =1 ; i<=n ;i++){
for(j=1;j<=m;j++)
cout << a[i][j] << " " ;
cout << endl;
}
for (j=1;j<=m;j++)
{
int p = 1;
for (i=1;i<=n;i++)
if (a[i][j] % 2 == 0)
p = p * a[i][j];
cout << "Produsul elemetelor pare de pe coloana " << j << " este : " << p << endl;
}
return 0 ;
}
Explicație: