fork download
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int n, num = 0;
  6. string t, s = "";
  7. char c, k;
  8.  
  9. int main()
  10. {
  11. cin >> n;
  12. cin >> t;
  13. for (int i = 0; i <n;) {
  14. c = t[i];
  15. num = 0;
  16. if (c >= 'a' && c <= 'z') {
  17. ++i;
  18. if (t[i] >= '0' && t[i] <= '9') {
  19. while (t[i] >= '0' && t[i] <= '9') {
  20. num *= 10;
  21. num += t[i] - '0';
  22. ++i;
  23. }
  24. for (int j = 0; j < num; ++j)
  25. cout << c;
  26. } else {
  27. cout << c;
  28. c = t[i];
  29. }
  30. }
  31. }
  32.  
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 3464KB
stdin
11
a2b3c4d5e10
stdout
aabbbccccdddddeeeeeeeeee