Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  
  8. int n, ile=1;
  9. cin >> n;
  10. string* tab = new string[n];
  11.  
  12. for(int i=0; i<n; i++)
  13. cin >> tab[i];
  14.  
  15. for(int i=0; i<n; i++)
  16. {
  17.  
  18. for(int j=1; j<=tab[i].length(); j++)
  19. {
  20.  
  21. if(tab[i][j]==tab[i][j-1]) ile++;
  22. else
  23. {
  24. if(ile>2)
  25. cout << tab[i][j-1] << ile;
  26. else if(ile==2)
  27. cout << tab[i][j-1] << tab[i][j-1];
  28. else
  29. cout << tab[i][j-1];
  30. ile=1;
  31. }
  32. }
  33. cout << endl;
  34. }
  35.  
  36. delete[] tab;
  37. return 0;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement