fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4.  
  5. const int MAX_LENGTH = 100;
  6.  
  7. int main() {
  8. char array[MAX_LENGTH];
  9. cin.getline(array, MAX_LENGTH);
  10. int length = strlen(array);
  11. int counter = 0, pos = 0;
  12. //
  13. for (int i = 0; i < length; ++i) {
  14. if (array[i] >= 'A' && array[i] <= 'Z') {
  15. array[i] = (char)(array[i] + 32);
  16. }
  17. }
  18. //cout << array <<"\n";
  19. int j = 0;
  20. for (int i = 0; i < length; ++i) {
  21. while (array[j] == array[i]) {
  22. // cout << array[j] << " " << array[i] <<" " << j <<"\n";
  23. ++counter;
  24. ++j;
  25. }
  26. if (array[i] != array[j]) {
  27.  
  28. i = j - 1;
  29. cout << counter <<array[i] ;
  30. counter = 0;
  31. //cout << i <<" ";
  32. } else {
  33. // pos = i;
  34.  
  35.  
  36. }
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0.01s 5288KB
stdin
aAaBBbccA
stdout
3a3b2c1a