Polnochniy

Untitled

Nov 22nd, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. const int N = 3;
  4. const int M = 3;
  5. int main()
  6. {
  7. setlocale(LC_ALL, "RUS");
  8. int a[N][N];
  9. int P[N];
  10. cout << "Введите элменты массива . Найти произведение положительныъ элементов строки" << endl;
  11. for (int k = 0; k < N; k++)
  12. {
  13. P[k] = { 1 };
  14. }
  15. for (int i = 0; i < N; i++)
  16. {
  17. for (int j = 0; j < M; j++)
  18. {
  19. cin >> a[i][j];
  20. }
  21. cout << endl;
  22. }
  23. cout << "____________________________________" << endl;
  24. for (int i = 0; i < N; i++)
  25. {
  26. for (int j = 0; j < M; j++)
  27. {
  28. if (a[i][j] > 0)
  29. {
  30. P[i] *= a[i][j];
  31. }
  32.  
  33.  
  34. else if (a[i] < 0 && a[j] > 0)
  35. {
  36. P[i] = a[i][j] * 0;
  37. P[j] = a[i][j];
  38. }
  39. cout << a[i][j] << " ";
  40. }
  41. cout << endl;
  42. }
  43.  
  44. cout << endl;
  45. for (int j = 0; j < M; j++)
  46. {
  47. cout << "Произведение положительных элементов строки матриц равна = ";
  48. cout << P[j] << " " << endl;
  49. }
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment