Advertisement
Polnochniy

Untitled

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