fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define name "MAX2CHIEU"
  5. const int MAXN = 2e5+5;
  6.  
  7. int a[1005][1005], m, n;
  8. int GTLN = -MAXN, GTNN = MAXN;
  9.  
  10. void setIO(){
  11. ios_base::sync_with_stdio(0);
  12. cin.tie(0); cout.tie(0);
  13. if (fopen(name".inp", "r")){
  14. freopen(name".inp", "r", stdin);
  15. freopen(name".out", "w", stdout);
  16. }
  17. }
  18.  
  19. void inp(){
  20. cin >> m >> n;
  21. for (int i = 1; i<=m; i++){
  22. for (int j = 1; j<=n; j++){
  23. cin >> a[i][j];
  24. if (a[i][j] > GTLN)
  25. GTLN = a[i][j];
  26. if (a[i][j] < GTNN)
  27. GTNN = a[i][j];
  28. }
  29. }
  30. }
  31.  
  32.  
  33. void solve(){
  34. cout << "GTLN: " << GTLN << "\n";
  35. for (int i = 1; i<=m; i++)
  36. for (int j = 1; j<=n; j++)
  37. if (a[i][j] == GTLN)
  38. cout << i << " " << j << "\n";
  39.  
  40. cout << "GTNN: " << GTNN << "\n";
  41. for (int i = 1; i<=m; i++)
  42. for (int j = 1; j<=n; j++)
  43. if (a[i][j] == GTNN)
  44. cout << i << " " << j << "\n";
  45.  
  46. }
  47.  
  48. int main(){
  49. setIO(); // Nhập xuất file
  50. inp(); // Nhập dữ liệu (có nội dung trong chương trình con hay không cũng được)
  51. solve(); // Giải quyết vấn đề của đề bài đưa ra
  52. }
Success #stdin #stdout 0s 5324KB
stdin
4 4
1 -2 3 4
5 6 -7 8 
2 2 3 -4 
8 3 -8 6 
stdout
GTLN: 8
2 4
4 1
GTNN: -8
4 3