Task - in the title of the topic. There is a code that needs to be redone.

Help please, if you can.

#include <conio.h> #include <iostream> #include <math.h> #include <cstdlib> #include <stdlib.h> // Для каждой строки напечатать номера столбцов, которые имеют отрицательные элементы using namespace std; int main() { int A[4][7]; setlocale(LC_ALL, "Russian"); int sum = 0, n; printf("Выберите метод заполнения массива: \n"); printf("1 - вручную: "); printf("2 - рандом: "); printf("3 - рандом: "); scanf("%d",&n); printf("Полученный вид матрицы 4*7:\n"); for (int j = 0; j < 7; ++j) { for (int i = 0; i < 4; ++i) { if (n == 2){ A[i][j] = i + j; printf(" %d", A[i][j]); } else if(n == 3){ A[i][j] = rand() % -10 - 5; printf(" %d",A[i][j]); } else{ printf("A[%d][%d] = ", j, i); scanf("%d", &A[i][j]); } } printf("\n"); } for (int i = 0; i < 4; ++i) { for (int j = 0; j< 7; ++j) { if (A[i][j] < 0) sum = sum + A[i][j]; } printf("Сумма элементов в столбце |%d| равна %d.\n", i+1,sum); sum = 0; } system("pause"); return 0; } 

Closed due to the fact that off-topic participants Viktorov , Vladimir Martyanov , Ainar-G , MedvedevDev , Denis Bubnov 22 Dec '17 at 5:30 .

It seems that this question does not correspond to the subject of the site. Those who voted to close it indicated the following reason:

  • " Learning tasks are allowed as questions only on the condition that you tried to solve them yourself before asking a question . Please edit the question and indicate what caused you difficulties in solving the problem. For example, give the code you wrote, trying to solve the problem "- Viktorov, Vladimir Martyanov, Ainar-G, MedvedevDev, Denis Bubnov
If the question can be reformulated according to the rules set out in the certificate , edit it .

    1 answer 1

    Here, completed)

     #include <iostream> #include <math.h> #include <stdio.h> #include <cstdlib> #include <stdlib.h> // Для каждой строки напечатать номера столбцов, которые имеют отрицательные элементы using namespace std; int main() { int A[4][7]; setlocale(LC_ALL, "Russian"); int sum = 0, n; cout << "Выберите метод заполнения массива: \n"; cout << "1 - вручную: "; cout << "2 - рандом: "; cout << "3 - рандом: "; cin >> n; printf("Полученный вид матрицы 4*7:\n"); for (int j = 0; j < 7; ++j) { for (int i = 0; i < 4; ++i) { if (n == 2){ A[i][j] = i + j; printf(" %d", A[i][j]); } else if(n == 3){ A[i][j] = rand() % -10 - 5; printf(" %d",A[i][j]); } else{ printf("A[%d][%d] = ", j, i); scanf("%d", &A[i][j]); } } printf("\n"); } for (int i = 0; i < 4; ++i) { for (int j = 0; j< 7; ++j) { if (A[i][j] < 0) sum = sum + A[i][j]; } printf("Сумма отрицательных элементов в столбце |%d| равна %d.\n", i+1,sum); sum = 0; } for (int j = 0; j < 7; ++j) { printf("В строке |%d| отрицательные эелементы имеют следующие столбцы: ", j+1); for (int i = 0; i< 4; ++i) { if (A[i][j] < 0) printf("%d ", i+1); } printf("\n"); } system("pause"); return 0; } 
    • Everything works perfectly. Thank! - gmastrbit
    • @Hinc, always please) - Daniel Chizhevsky