Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <stdlib.h>
- using namespace std;
- void main() {setlocale( LC_ALL,"Russian" );
- int N,M,k=0;
- cout « "Вывести на экран количество особых элементов матрицы \nВведите количество строк:"; cin » N;
- cout « "Введите количество столбцов:"; cin » M;
- int **mas=new int*[N];
- int *mas_j = new int [M];
- for (int i = 0; i < M; i++)
- {
- mas_j[i] = 0;
- }
- for (int i = 0; i < N; ++i)
- mas[i] = new int [M];
- for (int i = 0; i < N; i++)
- {
- for (int j = 0; j < M; j++)
- {
- mas[i][j]=rand()%40;
- mas_j[j] += mas[i][j];
- cout«mas[i][j]«" ";
- }
- cout«"\n";
- }
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < M; j++) {
- if (mas[i][j] * 2 > mas_j[j] ) k++;
- }
- }
- cout « "Количество особых элементов:" « k « endl;
- system("pause");
- }
Advertisement
Add Comment
Please, Sign In to add comment