Advertisement
S_h_u_v_r_o

2161 Searching Subsequences

Dec 11th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int a,b,c,d,e,f,g=0,h,i;;
  6. char x[100],y[100];
  7.  
  8. while(scanf("%s%s",x,y)!=EOF)
  9. {
  10. printf("Caso #%d:\n",++g);
  11.  
  12. f=0;
  13. c=strlen(x);
  14. d=strlen(y);
  15. for(a=0;a<d;a++)
  16. {
  17. e=0;
  18. if(y[a]==x[0])
  19. {
  20. i=a;
  21. for(b=0;b<c;b++)
  22. {
  23. if(y[a]==x[b])
  24. {
  25.  
  26. e++;
  27. a++;
  28. }
  29. else
  30. {
  31. --a;
  32. break;
  33. }
  34.  
  35. }
  36. if(e==c)
  37. {
  38. f++;
  39. h=i;
  40. --a;
  41. }
  42. }
  43.  
  44. }
  45. if(f==0){printf("Nao existe subsequencia\n\n");}
  46. else
  47. {
  48. printf("Qtd.Subsequencias: %d\nPos: %d\n\n",f,h);
  49. }
  50. }
  51.  
  52. return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement