fork(2) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4. int n, zap = 1,lol;
  5. string s;
  6. char z, z2, z3;
  7. int main() {
  8. ios::sync_with_stdio(false);
  9. cin >> n;
  10. lol=n-1;
  11. for (int j = 0; j < n; j++) {
  12.  
  13. cin >> s;
  14. for (int i = 0; i <= s.length(); i++) {
  15.  
  16. if (s[i]== s[i + 1] ) {
  17. zap++;
  18. } else {
  19.  
  20. if (zap > 2) {
  21. cout << s[i] << zap;
  22. zap=1;
  23. } else if(zap<2) {
  24. cout << s[i];
  25. zap=1;
  26. }else if(zap==2){
  27.  
  28. cout<<s[i-1]<<s[i];
  29. zap=1;
  30. }
  31. }
  32.  
  33. }
  34. zap=1;
  35.  
  36. cout<<endl;
  37. }
  38. }
Success #stdin #stdout 0.01s 5516KB
stdin
Standard input is empty
stdout
Standard output is empty