online compiler and debugger for c/c++

code. compile. run. debug. share.
Source Code    Language
import copy class TOTO: def __init__(self, tipp1, tipp2): self.tipp1 = tipp1 self.tipp2 = tipp2 self.column_n = 0 def value_exchange1(self): """A tipp1 lista elemeit 0 indextől kezdődően lecseréli a tipp2 lista nem nullás elemeivel. Minden egyes elem csere új tippsort hoz létre.""" i = 0 self.column_n = 0 while i < len(self.tipp1): # Ha nem '0' az elem if self.tipp2[i] != "0": # A tipp1 listában egy elem csere self.tipp1[i] = self.tipp2[i] # A felhasznált elemet nullázza tipp2-ben. self.tipp2[i] = "0" # Eggyel több oszlop beállítás self.column_n += 1 print('Tipposzlop', self.column_n, self.tipp1) i += 1 def value_exchange2(self): """A tipp1 lista csak egy elemét változtatja meg ciklusban. A következő elem változásához az eredeti változás mentes tipp1 sort használja Minden egy elem cseréje új tippsort hoz létre.""" self.column_n = 4 for index, elem in enumerate(self.tipp2): # Ciklusonkénti mélymásolás a new_list -hez. new_list = copy.deepcopy(self.tipp1) # A mélymásolt lista egy elemét cseréli if elem != '0': new_list[index] = self.tipp2[index] # Eggyel több oszlop beállítás self.column_n += 1 print('Tipposzlop', self.column_n, new_list) if __name__ == "__main__": lista1 = ['1', '1', '1', 'x', 'x', 'x', '1', '1', '1', 'x', 'x', 'x', 'x'] lista2 = ['2', '0', 'x', '0', '0', '0', '0', '0', '0', '0', '0', '1', '2'] print('Fő oszlop 0', lista1) app = TOTO(lista1, lista2) app.value_exchange1() app.value_exchange2()
import copy class TOTO: def __init__(self): super().__init__() @staticmethod def value_exchange1(tipp1, tipp2): """A tipp1 lista elemeit 0 indextől kezdődően lecseréli a tipp2 lista nem nullás elemeivel. Minden egyes elem csere új tippsort hoz létre.""" i = 0 column_number = 0 while i < len(tipp1): # Ha nem '0' az elem if tipp2[i] != "0": # A tipp1 listában egy elem csere tipp1[i] = tipp2[i] # A felhasznált elemet nullázza tipp2-ben. tipp2[i] = "0" # Eggyel több oszlop beállítás column_number += 1 print('Tipposzlop', column_number, tipp1) i += 1 @staticmethod def value_exchange2(tipp1, tipp2): """A tipp1 lista csak egy elemét változtatja meg ciklusban (loop). A következő elem változásához az eredeti változás mentes tipp1 sort használja Minden egy elem cseréje új tippsort hoz létre.""" column_number = 4 for index, elem in enumerate(tipp2): # Ciklusonkénti mélymásolás a new_list -hez. new_list = copy.deepcopy(tipp1) # A mélymásolt lista egy elemét cseréli if elem != '0': new_list[index] = tipp2[index] # Eggyel több oszlop beállítás column_number += 1 print('Tipposzlop', column_number, new_list) if __name__ == "__main__": lista1 = ['1', '1', '1', 'x', 'x', 'x', '1', '1', '1', 'x', 'x', 'x', 'x'] lista2 = ['2', '0', 'x', '0', '0', '0', '0', '0', '0', '0', '0', '1', '2'] print('Fő oszlop 0', lista1) app = TOTO() app.value_exchange1(lista1, lista2) app.value_exchange2(lista1, lista2)

Compiling Program...

Command line arguments:
Standard Input: Interactive Console Text
×

                

                

Program is not being debugged. Click "Debug" button to start program in debug mode.

#FunctionFile:Line
VariableValue
RegisterValue
ExpressionValue