fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4. using namespace std;
  5.  
  6. //BFF -- best friend forever
  7. //IDK -- I don't know
  8. //JK -- just kidding
  9. //TMI -- too much information
  10. //TTYL -- talk to you later
  11.  
  12. int main(){
  13.  
  14. int i;
  15. string input,output;
  16.  
  17. string bff = "best friend forever";
  18. string idk = "I don't know";
  19. string jk = "just kidding";
  20. string tmi = "too much information";
  21. string ttyl = "talk to you later";
  22.  
  23.  
  24.  
  25.  
  26. cout<<"Enter text: ";
  27. getline(cin,input);
  28.  
  29. input.resize(2*input.size());
  30.  
  31. output = input;
  32.  
  33. for( i = input.find("BFF");i>=0; i = output.find("BFF")){
  34.  
  35.  
  36. output.replace(i,3,bff);
  37. }
  38.  
  39. i = input.find("IDK");
  40.  
  41. if(i>=0){
  42.  
  43. output = input;
  44. output.replace(i,3,idk);
  45. }
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52. cout<<"\nYou entered: "<<input;
  53. cout<<"\nExpanded: "<<output;
  54.  
  55.  
  56. return 0;
  57. }
Success #stdin #stdout 0s 15232KB
stdin
Your BFF, my BFF, and her BFF are all there.
stdout
Enter text: 
You entered: Your BFF, my BFF, and her BFF are all there.
Expanded: Your best friend forever, my best friend forever, and her best friend forever are all there.