Advertisement
Guest User

Untitled

a guest
Dec 12th, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. string str1, str2, str3;
  6.  
  7. cout << "Please, enter first string: ";
  8. cin>>str1;
  9. int n1=str1.length();
  10. char vect1[n1];
  11. for (int i=0; i<n1; i++)
  12. {vect1[i]=str1[i];}
  13.  
  14. cout << "Please, enter second string: ";
  15. cin>>str2;
  16. int n2=str2.length();
  17. char vect2[n2];
  18. for (int i=0; i<n2; i++)
  19. {vect2[i]=str2[i];}
  20.  
  21. cout << "Please, enter third string: ";
  22. cin>>str3;
  23. int n3=str3.length();
  24. char vect3[n3];
  25. for (int i=0; i<n3; i++)
  26. {vect3[i]=str3[i];}
  27.  
  28.  
  29. int i=0, j=0, c=0, k;
  30. while (i<n1 && j<n3)
  31. {
  32. if (vect1[i]!=vect3[j])
  33. {
  34. if (c>0)
  35. {
  36. k=0;
  37. while (k<c)
  38. {
  39. cout<<vect1[k];
  40. k++;
  41. }
  42. i=0;
  43. c=0;
  44. }
  45. if (c==0)
  46. {
  47. cout<<vect3[j];
  48. j++;
  49. }
  50. }
  51. if (vect1[i]==vect3[j])
  52. {
  53. i++;
  54. j++;
  55. c++;
  56. }
  57. if (c==n1)
  58. {
  59. i=0;
  60. c=0;
  61. for (int k=0; k<n2; k++)
  62. cout<<vect2[k];
  63. }
  64. }
  65. return 0;
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement