#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;
===== PascalABC.NET =====
1)
begin
var a := ArrRandom(10, -80, 79);
a.Println;
var (j, k) := (-1, 0);
for var i := 0 to a.High do
if a[i].IsEven then
k += 1;
if k = 5 then
j := i;
break
end
end;
if j = -1 then
Println('Нет достаточного числа четных элементов')
a[j] := Sqr(a[j]);
a.Println
end.
2)
var imax := a.IndexMax;
a[imax] -= 100;
Swap(a[imax], a[a.High]);
#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;
}
===== PascalABC.NET =====
1)
begin
var a := ArrRandom(10, -80, 79);
a.Println;
var (j, k) := (-1, 0);
for var i := 0 to a.High do
if a[i].IsEven then
begin
k += 1;
if k = 5 then
begin
j := i;
break
end
end;
if j = -1 then
Println('Нет достаточного числа четных элементов')
else
begin
a[j] := Sqr(a[j]);
a.Println
end
end.
2)
begin
var a := ArrRandom(10, -80, 79);
a.Println;
var imax := a.IndexMax;
a[imax] -= 100;
Swap(a[imax], a[a.High]);
a.Println
end.