Advertisement
Kawsar_Hossain

Incomplete

Aug 9th, 2020
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. char s1[50],s2[50],s3[50];
  6. int i,j,k,l,m;
  7. printf("Enter first string: ");
  8. gets(s1);
  9. printf("Enter second string: ");
  10. gets(s2);
  11. char S1[50],S2[50];
  12. strcpy(s1,S2);
  13. strcpy(s2,S2);
  14. k=0;
  15. for(i=0,j=0;S1[i]!='\0';)
  16. {
  17. if(S1[i]==S2[j])
  18. {
  19. s3[k]=S1[i];
  20. k++;
  21. for(l=i;S1[i]!='\0';l++)
  22. {
  23. S1[i]=S1[i+1];
  24. }
  25. for(m=j;S2[m]!='\0';m++)
  26. {
  27. S2[m]=S2[m+1];
  28. }
  29.  
  30. }
  31. if(s1[i]!=s2[j])
  32. {
  33. for(l=j;s2[l]!='\0';l++)
  34. {
  35. if(S1[i]==S2[l])
  36. {
  37. s3[k]=S1[i];
  38. k++;
  39.  
  40.  
  41. break;
  42. }
  43. }
  44. }
  45. }
  46. s3[k]='\0';
  47. printf("%s", s3);
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement