#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int a[5][5] =
{
{4,-5,8,-3,1},
{-3,8,-1,1,-8},
{9,6,6,-3,-7},
{-7,-3,3,6,-7},
{7,-3,-6,5,0},
};
int b[5][5];
int i, j, cp, cm, sp, sm;
setlocale(LC_ALL, "Russian");
cout << "Массив A";
for (i = 0; i < 5; i++) {
cout << endl;
for (j = 0; j < 5; j++) {
cout << setw (4) << a[i][j];
}
}
cp = cm = sp = sm = 0;
for (i = 0; i < 5; i++) {
for (j = 0; j < 5; j++) {
if (a[i][j] >= -5)
b[i][j] = a[i][j];
else
b[i][j] = - a[i][j];
if (a[i][j] > 0) {
cp++;
sp += a[i][j];
}
if (a[i][j] < 0) {
cm++;
sm += a[i][j];
}
}
}
cout << endl << endl;
cout << "Среднее значение положительных элементов = " << (float) sp / cp << endl;
cout << "Среднее значение отрицательных элементов = " << (float) sm / cm << endl << endl;
cout << "Массив B";
for (i = 0; i < 5; i++) {
cout << endl;
for (j = 0; j < 5; j++) {
cout << setw(4) << b[i][j];
}
}
return 0;
}
Const width = 10
Sub Ìàêðîñ1()
Dim Sum(heigth - 1, width - 1)
Dim Product(heigth - 1, width - 1)
For i = 0 To heigth - 1
For j = 0 To width - 1
Sum(i, j) = i + j
Product(i, j) = i * j
Next j
Next i
Call Show(Sum, 0, 0)
Call Show(Product, 0, 12)
End Sub
Sub Show(ByRef m, dx, dy)
For i = 0 To heigth - 1
For j = 0 To width - 1
ActiveSheet.Cells(dx + i + 1, dy + j + 1).Value = Hex(m(i, j))
Next j
Next i
End Sub