Advertisement
Guest User

Untitled

a guest
May 26th, 2019
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. #include <Windows.h>
  2. #include<iostream>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <vector>
  6. #include <ctime>
  7. #include <fstream>
  8.  
  9. #define ld long double
  10. #define sp(X) setprecision(X) << fixed
  11. const ld eps = 1e-9;
  12. void z3()
  13.  
  14. {
  15. int i, j, positivSum=0, negativSum=0; const int n=3, m=3;
  16. int arr[n][m];
  17. cout<<"введите массив\n";
  18. for (i=0; i<n; i++)
  19. {
  20. for (j=0; j<m; j++) cin>>arr[i][j];
  21. }
  22. for (i=0; i<n; i++)
  23. {
  24. for (j=0; j<m; j++)
  25. {
  26.  
  27. if (arr[i][j]>=0) positivSum+=arr[i][j];
  28. else negativSum+=arr[i][j];
  29. }
  30. cout<<"сумма положительных элементов строки №"<<i+1<<" = "<<positivSum<<" , сумма отрицательных элементов = "<<negativSum<<"\n";
  31. positivSum=0; negativSum=0;
  32. }
  33. for (j=0; j<m; j++)
  34. {
  35. for (i=0; i<n; i++)
  36. {
  37.  
  38. if (arr[i][j]>=0) positivSum+=arr[i][j];
  39. else negativSum+=arr[i][j];
  40. }
  41. cout<<"сумма положительных элементов столбца №"<<j+1<<" = "<<positivSum<<" , сумма отрицательных элементов = "<<negativSum<<"\n";
  42. positivSum=0; negativSum=0;
  43. }
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement