fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3. int main(){
  4. int t,n,sl;
  5. string b,slowo=" ";
  6. char l;
  7. cin>>t;
  8. for(int i=0;i<t;i++){
  9. cin>>b;
  10. sl=slowo.length()-1;
  11. if(b=="DODAJ"){
  12. cin>>l;
  13. if(slowo[sl]!=0){
  14. slowo=slowo+l;
  15. }
  16. else{
  17. slowo[sl]=l;
  18. }
  19.  
  20. }
  21. else if(b=="USUN"){
  22. cin>>n;
  23. for(int j=0;j<n;j++){
  24. slowo[sl-j]=0;
  25. }
  26. }
  27. else if(b=="ZAMIEN"){
  28. cin>>l;
  29. if(slowo.length()>1){
  30. slowo[sl]=l;
  31. }
  32.  
  33. }
  34.  
  35. }
  36. for(int i=0;i<sl+2;i++){
  37. if(t==0){
  38. break;
  39. }
  40. if(slowo[i]!=32&&slowo[i]!=0){
  41. cout<<slowo[i];
  42. }
  43. }
  44. }
  45.  
Success #stdin #stdout 0.01s 5484KB
stdin
12
DODAJ A
ZAMIEN P
DODAJ B
ZAMIEN O
DODAJ C
ZAMIEN M
DODAJ K
ZAMIEN O
DODAJ F
ZAMIEN C
DODAJ G
ZAMIEN Y
stdout
POMOCY