fork(2) download
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9. string napis;
  10. int proby;
  11. cin >> proby;
  12. for (int i = 0; i < proby; i++)
  13. {
  14. cin >> napis;
  15. int dlugosc = napis.length();
  16. int licznik = 1;
  17. for (int j = 0; j < dlugosc; j++)
  18. {
  19. if (napis[j] == napis[j + 1])
  20. {
  21. licznik++;
  22. }
  23. else
  24. {
  25. cout << napis[j];
  26. if (licznik >= 3)
  27. {
  28. cout << licznik;
  29. licznik = 1;
  30. }
  31. else if(licznik == 2)
  32. {
  33. cout << napis[j];
  34. licznik = 1;
  35. }
  36. }
  37.  
  38. }
  39. cout << endl;
  40. }
  41. return 0;
  42. }
Success #stdin #stdout 0s 4232KB
stdin
4
OPSS
ABCDEF
ABBCCCDDDDEEEEEFGGHIIJKKKL
AAAAAAAAAABBBBBBBBBBBBBBBB
stdout
OPSS
ABCDEF
ABBC3D4E5FGGHIIJK3L
A10B16