fork download
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main(){
  5. int n, m, arr[100][100], maximum = -1e9;
  6. cin >> n >> m;
  7. for(int i = 0; i < n; i++){
  8. for(int j = 0; j < m; j++){
  9. cin >> arr[i][j];
  10. }
  11. }
  12. cout << "Max of each row: ";
  13. for(int i = 0; i < n; i++){
  14. for(int j = 0; j < m; j++){
  15. maximum = max(maximum, arr[i][j]);
  16. }
  17. cout << maximum << " ";
  18. maximum = -1e9;
  19. }
  20. }
  21.  
Success #stdin #stdout 0s 5304KB
stdin
3 4
1 2 3 4
5 6 7 8 
9 10 11 12
stdout
Max of each row: 4 8 12