Advertisement
Guest User

SufixPrefix02

a guest
Nov 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3. using namespace std;
  4. //sa se determine cel mai lung prefix comun
  5. //cel mai lung sufix comun
  6. int main()
  7. {
  8. char S[256];
  9. char P[256];
  10.  
  11. int i;
  12. cin>>S;
  13. strcpy(P,S);
  14. //prefixe
  15. for(i=strlen(S)-1;i>=0;i--){
  16. cout<<S<<'\n';
  17. S[i]=0;
  18. }
  19. //sufixe
  20. for(i=0;i<strlen(P);i++)
  21. cout<<P+i<<'\n';
  22. return 0;
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement