Наши проекты:
Журнал · Discuz!ML · Wiki · DRKB · Помощь проекту |
||
ПРАВИЛА | FAQ | Помощь | Поиск | Участники | Календарь | Избранное | RSS |
[18.116.118.198] |
|
Сообщ.
#1
,
|
|
|
До 1 октября надо сдать работу в институт. Прислали уже готовое решение, только вот прислали решение на питоне. Необходимо на Delphi. Помогите плиз:
import Tkinter def pushed0(): push("0") def pushed1(): push("1") def pushed2(): push("2") def pushed3(): push("3") def pushed4(): push("4") def pushed5(): push("5") def pushed6(): push("6") def pushed7(): push("7") def pushed8(): push("8") def pushed9(): push("9") def pushed10(): push("+") def pushed11(): push("-") def pushed12(): push("/") def pushed13(): push("*") def pushed14(): push("(") def pushed15(): push(")") def pushed16(): push("=") expression='' operand='' def push(a): global expression,operand,entry if expression : if expression[-1] in ["+","-","*","/","="] and a in ["+","-","*","/","="]: expression=expression[:-1] expression+=a operand+=a if expression[-1] in ["+","-","*","/","=",")"]: entry["text"]=str(spelling(expression[:-1]+"=")) operand='' else: entry["text"]=operand digitCommand=[pushed0, pushed1, pushed2, pushed3, pushed4, pushed5, pushed6, pushed7, pushed8, pushed9, pushed10, pushed11, pushed12, pushed13, pushed14, pushed15, pushed16] main=Tkinter.Tk() digitNumber=-1 for digit in ["0","1","2","3","4","5","6","7","8","9","+","-","/","*","(",")","="]: digitNumber+=1 digitButton=Tkinter.Button(main, text=str(digit),command=digitCommand[digitNumber]) digitButton.pack(side=Tkinter.LEFT, padx=0, pady=0) entry=Tkinter.Label(main,text="0") entry.pack(side=Tkinter.LEFT, padx=0, pady=0) def spelling(string): operand='' result=0 parenthesis=0 operation='+' cashedResults=[] cashedOperations=[] cashIndex=-1 for symbolnumber in range(0,len(string)): symbol=string[symbolnumber] if not parenthesis and symbol in ['1','2','3','4','5','6','7','8','9','0']: operand+=symbol elif not parenthesis and symbol in ['+','-','*','/','=',')']: if operation=='+': result+=float(operand) elif operation=='-': result-=float(operand) elif operation=='*': result*=float(operand) elif operation=='/': result/=float(operand) operation = symbol operand='' elif symbol=='(': parenthesis+=1 operand=spelling(string[symbolnumber+1:]) if operation=='+': result+=float(operand) elif operation=='-': result-=float(operand) elif operation=='*': result*=float(operand) elif operation=='/': result/=float(operand) operation = symbol operand='' if symbol==')': if parenthesis: parenthesis-=1 else: return result if symbol=='=': return result print spelling('12+2-(7*5+(14-3=') main.mainloop() |
Сообщ.
#2
,
|
|
|
Python Delphi
import uses def func_name(var_nam): function func_name(var_nam:нужен_тип):нужен_тип = On delphi := Добавлено чем еще? |
Сообщ.
#3
,
|
|
|
Если не найдёшь помощи , советую ещё также обратиться на форум по Python.
|