fork download
  1. #include <iostream>
  2. #include <cstring>
  3. int main()
  4. {
  5. using namespace std;
  6.  
  7. int n;
  8. cin >> n;
  9. int ile = 1;
  10. char wyraz[200];
  11.  
  12. for (int j = 0; j < n; j++) {
  13. cin >> wyraz;
  14. for (int i = 0; i < strlen(wyraz); i++) {
  15. if (ile <= 2)
  16. cout << wyraz[i];
  17. else if (ile >= 3) {
  18. cout << ile;
  19. i += ile - 1;
  20. cout << wyraz[i];
  21. }
  22. ile = 1;
  23. for (int z = i + 1; wyraz[z] == wyraz[i]; z++)
  24. ile++;
  25. }
  26. cout << endl;
  27. }
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 16064KB
stdin
2
OOOPSSS
AAAABBBB
stdout
O3PS3
41