Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- const int RIG=4, COL=4;
- const long A[][COL]={{1,2,3,4},
- {5,6,7,8},
- {9,0,1,2},
- {3,4,5,6}};
- long sommatoria (const long A[][COL],const int RIG);
- int main()
- {
- cout << "La sommatoria degli elementi piu' grandi in ogni riga della matrice A e' = " << sommatoria (A,RIG);
- return 0;
- }
- long sommatoria (const long A[][COL],const int RIG)
- {
- int i=0,k;
- long max_elem=0,temp;
- while (i<RIG)
- {
- k=0;
- temp=0;
- while (k<COL)
- {
- if (A[i][k]>temp) temp=A[i][k];
- k++;
- }
- max_elem+=temp;
- i++;
- }
- return max_elem;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement