Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 24th, 2012  |  syntax: C++  |  size: 0.51 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
This paste has a previous version, view the difference. Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include <string>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. int i=0,j=0;
  6. const int DIM=3;
  7. string substring_swap(string a[DIM], string s1, string s2)
  8. {
  9.     for (i=0;i<DIM;i++)
  10.     {
  11.        for (j=0;j<a[i].length()-s1.length;j++)
  12.        {
  13.          if (a[i].substr(j,j+a[i].substr))==s1);
  14.          a[i].substr()=s2;
  15.        }
  16.  
  17.     }
  18.     return a[i];
  19. }
  20.  
  21. int main()
  22. {
  23. string b[DIM]={"ciao pippo","pluto","lopresti ciao"};
  24. string s1="ciao", s2="muori";
  25. substring_swap(b,s1,s2);
  26. cout<<b;
  27. return 0;
  28. }