Guest User

Untitled

a guest
Jan 7th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include<iostream>
  2. #include <stdlib.h>
  3.  
  4. using namespace std;
  5.  
  6. void main() {setlocale( LC_ALL,"Russian" );
  7.  
  8. int N,M,k=0;
  9. cout « "Вывести на экран количество особых элементов матрицы \nВведите количество строк:"; cin » N;
  10. cout « "Введите количество столбцов:"; cin » M;
  11. int **mas=new int*[N];
  12. int *mas_j = new int [M];
  13. for (int i = 0; i < M; i++)
  14. {
  15. mas_j[i] = 0;
  16. }
  17. for (int i = 0; i < N; ++i)
  18. mas[i] = new int [M];
  19. for (int i = 0; i < N; i++)
  20. {
  21. for (int j = 0; j < M; j++)
  22. {
  23. mas[i][j]=rand()%40;
  24. mas_j[j] += mas[i][j];
  25. cout«mas[i][j]«" ";
  26. }
  27. cout«"\n";
  28. }
  29. for (int i = 0; i < N; i++) {
  30. for (int j = 0; j < M; j++) {
  31. if (mas[i][j] * 2 > mas_j[j] ) k++;
  32.  
  33.  
  34. }
  35. }
  36.  
  37.  
  38. cout « "Количество особых элементов:" « k « endl;
  39. system("pause");
  40. }
Advertisement
Add Comment
Please, Sign In to add comment