求一计算器程序,用BCB写的 谢谢!

artliu520 2004-10-17 12:57:30
求一计算器程序,用BCB写的 谢谢!
...全文
401 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
3xcom 2004-10-18
  • 打赏
  • 举报
回复
编程百例,,比较简单...........
WWW.CHINABCB.COM有一个超级全的.
lifang276 2004-10-18
  • 打赏
  • 举报
回复
void __fastcall TForm1::FormCreate(TObject *Sender)
{
a=0; //初始化
b=0;
c=0;
sum=0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
Edit3->Text=FloatToStr(b/sum);//平均数
Edit2->Text=FloatToStr(c);//求平方和
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
a=StrToFloat(Edit1->Text);//输入的数字
b=b+a; //求和
c=c+a*a; //求平方和
sum++;
Edit1->Clear();
Edit1->SetFocus();
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button3Click(TObject *Sender)
{
Close();
}
//---------------------------------------------------------------------------
依次类推求+ - * /
whp320 2004-10-18
  • 打赏
  • 举报
回复
我觉得这里应该更多的讨论一下技术性的问题,而不是这样提一个非技术性问题。比如你可以把你编写的计算器程序贴出来,遇到什么问题,我们大家一起来探讨。这样大家才可以一起提高,长长见识。
whitelion 2004-10-18
  • 打赏
  • 举报
回复
楼主大概是想找一个能计算公式的算法吧
有一个简单的,就是直接用sql语句
superyys 2004-10-18
  • 打赏
  • 举报
回复
用控件啦.
DEV express就有一个计算器啊!
artliu520 2004-10-18
  • 打赏
  • 举报
回复
大哥,我不会BCB啊 一直在做别的事情 可不可以给个完整的啊!急啊
ssyfrank 2004-10-18
  • 打赏
  • 举报
回复
可以自己做,简单!
artliu520 2004-10-18
  • 打赏
  • 举报
回复
To sunliwen780502(孙立文):
好像还差一个界面控件把?

用Delphi写的不要,只要BCB的 拜托
zdyyongjing 2004-10-18
  • 打赏
  • 举报
回复
C++Builder6 编程实例教程
里面有一个计算器程序,本中提供光盘,程序可运行。
gfh_79_0 2004-10-17
  • 打赏
  • 举报
回复
C++Builder 编程百例
sunliwen780502 2004-10-17
  • 打赏
  • 举报
回复
#include <vcl.h>
#pragma hdrstop
#include <math.h>
#include "Calc.h"

//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"

TForm1 *Form1;
float temp1;
float temp2;
int flag;
int append;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button1->Caption;
//单击1按钮
append=0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::FormCreate(TObject *Sender)
{
Form1->Edit1->Clear();
//清除文本框中的内容
temp1 = 0;
temp2 = 0;
flag = 0;
append = 0;
//变量赋初值
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button2Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button2->Caption;
//单击2按钮
append = 0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button3Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button3->Caption;
//单击3按钮
append = 0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button4Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button4->Caption;
//单击4按钮
append = 0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button5Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button5->Caption;
//单击5按钮
append = 0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button6Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button6->Caption;
//单击6按钮
append = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button7->Caption;
//单击7按钮
append = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button8->Caption;
//单击8按钮
append = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button9->Caption;
//单击9按钮
append = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button10Click(TObject *Sender)
{
if (append != 0) Form1->Edit1->Clear();
Form1->Edit1->Text = Form1->Edit1->Text + Form1->Button10->Caption;
//单击0按钮
append = 0;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button13Click(TObject *Sender)
{
flag = 1;
//设置加法标志
if (Form1->Edit1->Text != "")
temp1 = StrToFloat(Form1->Edit1->Text);
//为变量temp1赋值
//Form1->Edit1->Clear();
//清空文本框
append = 1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button14Click(TObject *Sender)
{
flag = 2;
//设置减法标志
if (Form1->Edit1->Text != "")
temp1 = StrToFloat(Form1->Edit1->Text);
//为变量temp1赋值
//Form1->Edit1->Clear();
//清空文本框
append = 1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button15Click(TObject *Sender)
{
flag = 3;
//设置乘法标志变量值
if (Form1->Edit1->Text != "")
temp1 = StrToFloat(Form1->Edit1->Text);
//为变量temp1赋值
//Form1->Edit1->Clear();
//清空文本框
append=1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button16Click(TObject *Sender)
{
flag = 4;
//设置除法标志
if (Form1->Edit1->Text != "")
temp1 = StrToFloat(Form1->Edit1->Text);
//为变量temp1赋值
//Form1->Edit1->Clear();
//清空文本框
append = 1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::Button11Click(TObject *Sender)
{
switch (flag)
{
case 1: temp2 = StrToFloat(Edit1->Text) + StrToFloat(temp1);
//进行加法运算
break;
case 2: temp2 = StrToFloat(temp1) - StrToFloat(Edit1->Text);
//进行减法运算
break;
case 3: temp2 = StrToFloat(Edit1->Text) * StrToFloat(temp1);
//进行乘法运算
break;
case 4: temp2 = StrToFloat(temp1) / StrToFloat(Edit1->Text);
//进行除法运算
}
Edit1->Text = FloatToStr(temp2);
//显示运算结果
append = 1;
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton1Click(TObject *Sender)
{
if (Form1->Edit1->Text != "")
Form1->Edit1->Text = FloatToStr(sin(StrToFloat(Form1->Edit1->Text)));
//计算正弦值
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton2Click(TObject *Sender)
{
if (Form1->Edit1->Text != "")
Form1->Edit1->Text = FloatToStr(cos(StrToFloat(Form1->Edit1->Text)));
//计算余弦值
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton3Click(TObject *Sender)
{
if (Form1->Edit1->Text != "")
Form1->Edit1->Text = FloatToStr(tan(StrToFloat(Form1->Edit1->Text)));
//计算正切值
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton4Click(TObject *Sender)
{
if (Form1->Edit1->Text != "")
Form1->Edit1->Text = FloatToStr(1 / tan(StrToFloat(Form1->Edit1->Text)));
//计算余切值
}
//---------------------------------------------------------------------------

void __fastcall TForm1::RadioButton5Click(TObject *Sender)
{
if (Form1->Edit1->Text != "")
Form1->Edit1->Text = FloatToStr(log(StrToFloat(Form1->Edit1->Text)));
//计算对数值
}
//---------------------------------------------------------------------------


void __fastcall TForm1::Button12Click(TObject *Sender)
{
Form1->Edit1->Clear();
//清除文本框中的内容
temp1 = 0;
temp2 = 0;
flag = 0;
//变量赋初值
}
//---------------------------------------------------------------------------
Javpp 2004-10-17
  • 打赏
  • 举报
回复
有一本书上讲了怎么做了的,你可以去查一查,不过书名我忘记了:)

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧