bogdanNiculeasa

https://www.pbinfo.ro/probleme/551/elevi

Jul 24th, 2023
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int m, n;
  8. cin >> m >> n;
  9. int matrice[m][n]; // matrice cu m linii si n coloane
  10. // citim fiecare linie
  11. for (int i = 0; i < m; i++) {
  12. // citim elementele fiecarei linii
  13. for (int j =0; j < n; j++) {
  14. cin >> matrice[i][j];// citeste de la tastatura elementul pentru linia i si col j
  15. }
  16. }
  17.  
  18.  
  19. int max = -1;
  20. for (int i = 0; i < m; i++) {
  21. for (int j = 0; j < n; j++) {
  22. if (matrice[i][j] > max) {
  23. max = matrice[i][j];
  24. }
  25. }
  26. }
  27. int cnt = 0;
  28. for (int i = 0; i < m; i++) {
  29. for (int j = 0; j < n; j++) {
  30. if (matrice[i][j] == max) {
  31. cnt++;
  32. break;
  33. }
  34. }
  35.  
  36. }
  37. cout << max <<" " << cnt;
  38. return 0;
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment