Jump to content
TheTime

C++ str_replace

Recommended Posts

Posted

What about this or:

>>> inlist = raw_input("Text: ").split()
Text: mere portocale ana are mere
>>> print " ".join(inlist[2:]).replace(inlist[0], inlist[1])
ana are portocale

P.S.: In sursa de C++ replace face toata treaba, main e doar de fatada.

Posted
What about this or:

>>> inlist = raw_input("Text: ").split()
Text: mere portocale ana are mere
>>> print " ".join(inlist[2:]).replace(inlist[0], inlist[1])
ana are portocale

P.S.: In sursa de C++ replace face toata treaba, main e doar de fatada.

Asa am facut si eu initial, pune testul meu si vezi ce se intampla :)

P.S vorbesc de implementarea de pe paste-bin

Posted

Da, prima oara inainte sa incep scriptul m-am gandit la asta, dar doar din punct de vedere optimal nu si ca ar putea intra in bucla infinita, oricum am editat codul de pe pastebin, adaugand inca o singura linie in functia replace si face ce face si a ta.

Inca o data scuze, cum m-am gandit ca ar scadea putin din viteza cautarea redundanta a valorilor deja inlocuite mi-am spus ca la nivelul asta nu conteaza acele nanosecunde in plus si am trecut mai departe, dar am uitat de acel caz, oricum am pus doar o linie in plus, acea incrementare la pos.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...