#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
int a[5][5] = { 0 }, i, j, s, b[5] = { 0 };
double p;
ifstream f("input.txt");
if (!f.is_open())
cout << "error";
else
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
f >> a[i][j];
}
f.close();
s = 0;
if(a[i][i]<0)
s += a[i][i];
cout << "sum=" <<s<<endl;
p = 1;
for (int j = 0; j < 5; j++)
p *= 2*sin(abs(a[3][j]))+0.3*j;
cout << "P=" << p << endl;
if(a[i][j]>0)
s += a[i][j];
b[j] = s;
cout << "massiv b: ";
cout << b[i] << " ";
return 0;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Verified answer
#include <iostream>
#include <fstream>
#include <cmath>
using namespace std;
int main()
{
int a[5][5] = { 0 }, i, j, s, b[5] = { 0 };
double p;
ifstream f("input.txt");
if (!f.is_open())
cout << "error";
else
{
for (i = 0; i < 5; i++)
for (j = 0; j < 5; j++)
f >> a[i][j];
}
f.close();
s = 0;
for (i = 0; i < 5; i++)
if(a[i][i]<0)
s += a[i][i];
cout << "sum=" <<s<<endl;
p = 1;
for (int j = 0; j < 5; j++)
p *= 2*sin(abs(a[3][j]))+0.3*j;
cout << "P=" << p << endl;
s = 0;
for (j = 0; j < 5; j++)
{
for (i = 0; i < 5; i++)
if(a[i][j]>0)
s += a[i][j];
b[j] = s;
s = 0;
}
cout << "massiv b: ";
for (i = 0; i < 5; i++)
cout << b[i] << " ";
return 0;
}