fork download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. int main() {
  6. char s[2000], aux[2000];
  7. int k = -1, cond, nr;
  8. cin.getline(s, 2000, 0);
  9. int lg = strlen(s);
  10. for (int a = 0; a < lg; ++a){
  11. if (isalpha(s[a])){
  12. nr = 1;
  13. if (s[a] == s[a + 1]){
  14. do {
  15. ++nr;
  16. ++a;
  17. }
  18. while(s[a] == s[a + 1]);
  19. }
  20. ++k;
  21. aux[k] = '0' + nr;
  22. ++k;
  23. aux[k] = s[a];
  24. }
  25. else {
  26. ++k;
  27. aux[k] = s[a];
  28. }
  29. }
  30. cout << aux;
  31. return 0;
  32. }
Success #stdin #stdout 0.01s 5284KB
stdin
jagger sold the cannnnon??
stdout
1j1a2g1e1r 1s1o1l1d 1t1h1e 1c1a4n1o1n??