fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int ilo_liter(string wyraz, int j){
  5. int a=0;
  6. for (j;j<wyraz.length(); j++){
  7. if (wyraz[j]==wyraz[j+1]) a++;
  8. else return a;
  9. }
  10. }
  11.  
  12. int main(){
  13. int n;
  14. int b=0;
  15. cin >> n;
  16. for (int i=0; i<n; i++){
  17. string wyraz;
  18. cin >> wyraz;
  19. for (int j=0; j<wyraz.length();){
  20. b= ilo_liter(wyraz, j)+1;
  21. if (b<=2) {
  22. if (b==1)cout<<wyraz[j];
  23. else cout<<wyraz[j]<<wyraz[j+1];
  24. j+=b;
  25. }
  26. else {
  27. cout<<wyraz[j]<<b;
  28. j+=b;
  29. }
  30. }
  31. cout<<endl;
  32. }
  33. return 0;
  34. }
Success #stdin #stdout 0.04s 4500KB
stdin
Standard input is empty
stdout