Решите это задания плиз на с++
Ответы на вопрос
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand((int)time(0));
const int n=4, m=8;
double a[n][m], sum_pos;
cout << "Matrix:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j]=0.1*(rand()%201 - 100);
cout << setw(7) << setprecision(1) << fixed << a[i][j];
}
cout << "\n";
}
cout << "Modified matrix:\n";
for (int i = 0; i < n; i++) {
sum_pos=0.;
for (int j = 0; j < m; j++)
if(a[i][j]>0.) sum_pos+=a[i][j];
for (int j = 0; j < m; j++) {
if(a[i][j]<0.) a[i][j]=sum_pos;
cout << setw(7) << setprecision(1) << fixed << a[i][j];
}
cout << "\n";
}
system("pause");
return 0;
}
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
using namespace std;
int main() {
srand((int)time(0));
const int n=4, m=8;
double a[n][m], sum_pos;
cout << "Matrix:\n";
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j]=0.1*(rand()%201 - 100);
cout << setw(7) << setprecision(1) << fixed << a[i][j];
}
cout << "\n";
}
cout << "Modified matrix:\n";
for (int i = 0; i < n; i++) {
sum_pos=0.;
for (int j = 0; j < m; j++)
if(a[i][j]>0.) sum_pos+=a[i][j];
for (int j = 0; j < m; j++) {
if(a[i][j]<0.) a[i][j]=sum_pos;
cout << setw(7) << setprecision(1) << fixed << a[i][j];
}
cout << "\n";
}
}