Advertisement
Guest User

Untitled

a guest
Nov 20th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int32_t main() {
  6. int n;
  7. cin >> n;
  8. int X[n][n];
  9. for(int i = 0; i < n; ++i) {
  10. for(int j = 0; j < n; ++j) {
  11. cin >> X[i][j];
  12. }
  13. }
  14. int Y[n], Z[n];
  15. fill(Y, Y + n, 0);
  16. fill(Z, Z + n, 0);
  17. for(int i = 0; i < n; ++i) {
  18. for(int j = 0; j < i + 1; ++j) {
  19. if(X[i][j] > 0) {
  20. Y[i] += X[i][j];
  21. Z[i]++;
  22. }
  23. }
  24. }
  25. for(int i = 0; i < n; ++i) {
  26. for(int j = 0; j < n; ++j) {
  27. cout << X[i][j] << " ";
  28. }
  29. cout <<" Y = " <<Y[i] << " Z = " << Z[i] << endl;
  30. }
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement