fork download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. string ex(){
  6. string s="",X;
  7. char c;int D;
  8. while(cin>>c){
  9. if(c=='['){
  10. cin>>D;
  11. X=ex();
  12. while(D--){
  13. s+=X;
  14. }
  15. }
  16. else if(c==']'){
  17. return s;
  18. }
  19. else{
  20. s+=c;
  21. }
  22. }
  23. return s;
  24. }
  25. int main(){
  26. cout<<ex();
  27. return 0;
  28. }
Success #stdin #stdout 0.01s 5276KB
stdin
AC[3FUN]
stdout
ACFUNFUNFUN