fork(3) download
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. using namespace std;
  6.  
  7. int liczbaTestow, dlugoscWyrazu, dlugoscCiagu=0;
  8. string wyraz;
  9.  
  10. int main()
  11. {
  12. cin >> liczbaTestow;
  13.  
  14. for (int j = 0; j < liczbaTestow; j++)
  15. {
  16. cin >> wyraz;
  17. dlugoscWyrazu = wyraz.length();
  18.  
  19. cout << wyraz[0];
  20.  
  21. for(int i=1;i<=dlugoscWyrazu;i++)
  22. {
  23. if(wyraz[i-1]==wyraz[i])
  24. dlugoscCiagu++;
  25. else if (dlugoscCiagu == 1)
  26. {
  27. cout << wyraz[i-1] << wyraz[i];
  28. dlugoscCiagu = 0;
  29. }
  30. else if (dlugoscCiagu > 1)
  31. {
  32. cout << dlugoscCiagu+1 << wyraz[i];
  33. dlugoscCiagu = 0;
  34. }
  35. else
  36. {
  37. cout << wyraz[i];
  38. dlugoscCiagu = 0;
  39. }
  40. }
  41. if (j!=liczbaTestow-1)
  42. cout << endl;
  43. }
  44.  
  45. return 0;
  46. }
  47.  
Success #stdin #stdout 0s 5016KB
stdin
Standard input is empty
stdout
Standard output is empty