簡單計算器

2021-05-09 12:59:32 字數 1797 閱讀 5941

unit unit1;

inte***ce

uses

windows, messages, sysutils, variants, classes, graphics, controls, forms,

dialogs, stdctrls, buttons,math;//math是數**算單元

type

tform1 = class(tform)

edit1: tedit;

edit2: tedit;

edit3: tedit;

speedbutton1: tspeedbutton;

speedbutton2: tspeedbutton;

speedbutton3: tspeedbutton;

speedbutton4: tspeedbutton;

speedbutton5: tspeedbutton;

speedbutton6: tspeedbutton;

speedbutton7: tspeedbutton;

statictext1: tstatictext;

procedure speedbutton1click(sender: tobject);

procedure speedbutton7click(sender: tobject);

private

public

end;

varform1: tform1;

implementation

procedure tform1.speedbutton1click(sender: tobject);

begin

statictext1.caption := tspeedbutton(sender).caption;

end;

procedure tform1.speedbutton7click(sender: tobject);

begin

if trim(statictext1.caption) = '+' then

edit3.text := floattostr(strtofloat(edit1.text)+

strtofloat(edit2.text));

if trim(statictext1.caption) = '-' then

edit3.text := floattostr(strtofloat(edit1.text)-

strtofloat(edit2.text));

if trim(statictext1.caption) = '*' then

edit3.text := floattostr(strtofloat(edit1.text)*

strtofloat(edit2.text));

if trim(statictext1.caption) = '/' then

edit3.text := floattostr(strtofloat(edit1.text)/

strtofloat(edit2.text));

if trim(statictext1.caption) = 'pow' then

edit3.text := floattostr(power(strtofloat(edit1.text),

strtofloat(edit2.text)));

if trim(statictext1.caption) = 'sqrt' then

edit3.text := floattostr(sqrt(strtofloat(edit1.text)));

end;

end.

簡單計算器

a 簡單計算器 crawling in process.crawling failed time limit 1000msmemory limit 32768kb64bit io format i64d i64u submit status description 讀入乙個只包含 的非負整數計算表示...

簡單計算器

問題描述 乙個最簡單的計算器,支援 四種運算。僅需考慮輸入輸出為整數的情況,資料和運算結果不會超過int表示的範圍。輸入 輸入只有一行,共有三個引數,其中第1 2個引數為整數,第3個引數為操作符 輸出 輸出只有一行,乙個整數,為運算結果。然而 1.如果出現除數為0的情況,則輸出 divided by...

簡單計算器

description 讀入乙個只包含 的非負整數計算表示式,計算該表示式的值。input 測試輸入包含若干測試用例,每個測試用例佔一行,每行不超過200個字元,整數和運算子之間用乙個空格分隔。沒有非法表示式。當一行中只有0時輸入結束,相應的結果不要輸出。output 對每個測試用例輸出1行,即該表...