fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int TEN = 10;
  5. const int MAX_SIZE = 20;
  6.  
  7. bool isRecreatives(int num) {
  8. return num / TEN / TEN == num / TEN % TEN && num / TEN % TEN == num % TEN;
  9. }
  10.  
  11. int main() {
  12. int n, m, matrix[MAX_SIZE][MAX_SIZE], distinctLines[MAX_SIZE] = {0};
  13. int highestRecreatives = 1;
  14. cin >> n >> m;
  15. for (int i = 0; i < n; ++i) {
  16. for (int j = 0; j < m; ++j) {
  17. cin >> matrix[i][j];
  18. distinctLines[i] += (int)isRecreatives(matrix[i][j]);
  19. }
  20. if (highestRecreatives < distinctLines[i]) {
  21. highestRecreatives = distinctLines[i];
  22. }
  23. }
  24. for (int i = 0; i < n; ++i) {
  25. if (distinctLines[i] == highestRecreatives) {
  26. for (int j = 0; j < m; ++j) {
  27. cout << matrix[i][j] << ' ';
  28. }
  29. cout << '\n';
  30. }
  31. }
  32. return 0;
  33. }
Success #stdin #stdout 0s 5268KB
stdin
3 3
123 900 111
342 444 222
110 666 999
stdout
342 444 222 
110 666 999