cp/m Posted July 5, 2010 Report Share Posted July 5, 2010 Am nevoie de ajutor pentru a gasi bug-ul in programul asta:import sysvar={}com=""i=0j=0comm=[]co=""print "##########Source##########"while co!="HALT": co=raw_input() comm.append(co) i=i+1print "##########Execution##########"while j<i: com=comm[j] if com[0:4]=="READ": var[com[6:7]]=input() if com[0:5]=="TELLN": if var.has_key(com[7:8]): print var[com[7:8]] elif com[0:4]=="TELL": if var.has_key(com[6:7]): print var[com[6:7]], if com[0:4]=="MAKE": var[com[5:6]]=0 if com[1:2]=="=": var[com[0:1]]=eval(com[2:len(com)]) if com[0:4]=="MOVE": if var.has_key(com[5:6]) and var.has_key(com[7:8]): var[com[5:6]]=var[com[7:8]] if com[0:3]=="PUT": if var.has_key(com[4:5]): var[com[4:5]]=com[6:7] j=j+1Incercati urmatorul program:e=12+3/2TELLN eHALTMie nu-mi merge. :S Quote Link to comment Share on other sites More sharing options...
Birkoff Posted July 5, 2010 Report Share Posted July 5, 2010 nu stiu pyton da cu ocazia asta am mai descoperit un cuvant nou "deburghificarea"daca imi zici si cum se traduce si in ce limba e esti tare cred ca o sa il folosesc cand joc spanzuratoarea sau fazan Quote Link to comment Share on other sites More sharing options...
Birkoff Posted July 5, 2010 Report Share Posted July 5, 2010 tare [end offtopic] Quote Link to comment Share on other sites More sharing options...
cmiN Posted July 5, 2010 Report Share Posted July 5, 2010 In primul rand vreau sa afirm ca e cel mai urat cod care l-am vazut vreodata, in al doilea rand te intreb de ce ai importat sys ?##########Source##########e=12+3/2TELLN eHALT##########Execution##########13Python | import sys var={} com="" i= - CmiN - 1jFmR9NT - Pastebin.comUnde ti-am pus cate un diez am facut eu corectura, greseli erau la valorile ce delimitau substring-urile, indexii aia dintre paranteze aplicate pe siruri, erau prea mari. Quote Link to comment Share on other sites More sharing options...
cp/m Posted July 5, 2010 Author Report Share Posted July 5, 2010 Multumesc cmiN! Gandeste-te ce eleganta am, daca asta este cel mai frumos cod scris de mine pana acum.Apropo: in py exista jump-uri? Quote Link to comment Share on other sites More sharing options...
cmiN Posted July 6, 2010 Report Share Posted July 6, 2010 Daca te referi la goto nu ... nu exista din mai multe motive: python e un limbaj de un nivel foarte inalt, cred ca cel mai inalt nivel posibil , iar instructiunea respectiva se foloseste mai mult in programarea low level, dar in python asa ceva ar fi foarte instabil si putin aiurea, de aceea poti folosi functiile.def func():....<bla bla>while <ala bala>:....func()....<bla bla>....if <ala bala>:........func() Quote Link to comment Share on other sites More sharing options...
cp/m Posted July 6, 2010 Author Report Share Posted July 6, 2010 ok. Multumesc. Quote Link to comment Share on other sites More sharing options...