Помогите дописать программу калькулятор, я написал простой калькулятор, а теперь надо чтобы этот калькулятор еще обсчитывал синус и косинус, вот код калькулятора
C++ |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
| //--------------------------------------------------------------------------
#include <vcl.h>
#include <stdlib.h>
#include <math.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
float a=0,m;
AnsiString z="";
bool zn=false;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn7Click(TObject *Sender)
{
if(Edit1->Text=="0" || zn==true) {Edit1->Text=((TButton*)Sender)->Caption; zn=false;}
else if (Edit1->Text!=0) Edit1->Text=Edit1->Text+((TButton*)Sender)->Caption;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn16Click(TObject *Sender)
{
BitBtn21->Click();
if(((TButton*)Sender)->Caption=="MS") {m=StrToInt(Edit1->Text); StaticText1->Caption=m;}
else if(((TButton*)Sender)->Caption=="M+") {m=m+StrToInt(Edit1->Text);StaticText1->Caption=m;Edit1->Text=m;zn=true;}
else if(((TButton*)Sender)->Caption=="MC") {m=0;StaticText1->Caption=m;Edit1->Text=0;}
else if(((TButton*)Sender)->Caption=="MR") {Edit1->Text=m;}
a=StrToFloat(Edit1->Text);
z=((TButton*)Sender)->Caption;
zn=true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn21Click(TObject *Sender)
{
if (z=="+") Edit1->Text=a+StrToInt(Edit1->Text);
else if (z=="-") Edit1->Text=a-StrToInt(Edit1->Text);
else if (z=="*") Edit1->Text=a*StrToInt(Edit1->Text);
else if (z=="/") Edit1->Text=a/StrToInt(Edit1->Text);
a=StrToFloat(Edit1->Text);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn18Click(TObject *Sender)
{
if(((TButton*)Sender)->Caption=="C") {a=0;z="";zn=false;Edit1->Text="0";}
else if(((TButton*)Sender)->Caption=="CE") {Edit1->Text="0";}
}
//--------------------------------------------------------------------------- |
|