Task :
Given a two-dimensional array of 2 rows and 4 columns. Create a program that organizes a one-dimensional array, each element of which is the number of negative elements of the original array in a row. Calculate the sum of the elements of the resulting array.
//Sedyolkin Yuriu Alekseevich 4103 //lab5 #include "stdafx.h" #include <cstdlib> #include <math.h> #include <iostream> #include <stdio.h> #include <locale.h> using namespace std; int _tmain(int argc, _TCHAR* argv[]) { setlocale(0, ""); system("cls"); int i, j, k; double s = 0; int a[2][4]; int b[2]; for (i = 0;i < 2;i++) { for (j = 0;j < 4;j++) { cout << "Введи a[" << i << "," << j << "]="; cin >> a[i][j]; cout << endl; } } for (i = 0;i < 2;i++) { for (j = 0;j < 4;j++) { cout << a[i][j] << " "; } cout << endl; } for (i = 0;i < 2;i++) { k = 0; for (j = 0;j < 4;j++) if (a[i][j] < 0) k++; b[j] = k; cout << b[j] << endl; } for (j = 0;j < 2;j++) s = b[j] + s; if (s == 0) cout << "Нет отрицательных значений в массиве а""\n"; else cout << "Сумма элементов преобразованного массива: " << s << endl; system("pause"); return 0; } The sum of the elements of the second array at the end of the program is not calculated correctly.