Advertisement
Guest User

Cod Inversare caractere tralalla

a guest
Feb 28th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. Cod afisare inversa sir de caractere
  2.  
  3. #include <iostream>
  4. #include <cstring>
  5.  
  6. using namespace std;
  7. char s[101],t[101],*p;
  8. int lgmax,n,b,i,j,f,l;
  9. int main()
  10. {
  11. cin.getline(s,101);
  12. strcpy(t,s);
  13. p=strtok(t+1,"#");
  14. while(p)
  15. {
  16. l=strlen(p);
  17. if(l>lgmax) lgmax=l;
  18. p=strtok(NULL,"#");
  19. }
  20.  
  21. p=strtok(s+1,"#");
  22. while(p)
  23. {
  24. l=strlen(p);
  25. if(l>lgmax)
  26. cout<<p<<"#";
  27. else
  28. {
  29. //ac
  30. for(i=l-1;i>=0;i--)
  31. cout<<p[i];
  32. cout<<"#";
  33. }
  34. p=strtok(NULL,"#");
  35.  
  36.  
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement