计算机程序源代码.docx
- 文档编号:9555944
- 上传时间:2023-02-05
- 格式:DOCX
- 页数:20
- 大小:16.55KB
计算机程序源代码.docx
《计算机程序源代码.docx》由会员分享,可在线阅读,更多相关《计算机程序源代码.docx(20页珍藏版)》请在冰豆网上搜索。
计算机程序源代码
计算机程序源代码
//jisuanqiDlg:
implementationfile
//
#include"stdafx.h"
#include"jisuanqi.h"
#include"jisuanqiDlg.h"
#include"math.h"
#ifdef_DEBUG
#definenewDEBUG_NEW
#undefTHIS_FILE
staticcharTHIS_FILE[]=__FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//CAboutDlgdialogusedforAppAbout
classCAboutDlg:
publicCDialog
{
public:
CAboutDlg();
//DialogData
//{{AFX_DATA(CAboutDlg)
enum{IDD=IDD_ABOUTBOX};
//}}AFX_DATA
//ClassWizardgeneratedvirtualfunctionoverrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtualvoidDoDataExchange(CDataExchange*pDX);//DDX/DDVsupport
//}}AFX_VIRTUAL
//Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg:
:
CAboutDlg():
CDialog(CAboutDlg:
:
IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
voidCAboutDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg,CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
//Nomessagehandlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CJisuanqiDlgdialog
CJisuanqiDlg:
:
CJisuanqiDlg(CWnd*pParent)
:
CDialog(CJisuanqiDlg:
:
IDD,pParent)
{
//{{AFX_DATA_INIT(CJisuanqiDlg)
m_num=0.0;
//}}AFX_DATA_INIT
//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32
m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
voidCJisuanqiDlg:
:
DoDataExchange(CDataExchange*pDX)
{
CDialog:
:
DoDataExchange(pDX);
//{{AFX_DATA_MAP(CJisuanqiDlg)
DDX_Text(pDX,IDC_EDIT1,m_num);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CJisuanqiDlg,CDialog)
//{{AFX_MSG_MAP(CJisuanqiDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1,OnButton1)
ON_BN_CLICKED(IDC_BUTTON2,OnButton2)
ON_BN_CLICKED(IDC_BUTTON3,OnButton3)
ON_BN_CLICKED(IDC_BUTTON4,OnButton4)
ON_BN_CLICKED(IDC_BUTTON5,OnButton5)
ON_BN_CLICKED(IDC_BUTTON6,OnButton6)
ON_BN_CLICKED(IDC_BUTTON7,OnButton7)
ON_BN_CLICKED(IDC_BUTTON8,OnButton8)
ON_BN_CLICKED(IDC_BUTTON9,OnButton9)
ON_BN_CLICKED(IDC_BUTTON14,OnButton0)
ON_BN_CLICKED(IDC_BUTTON15,OnButtonPoint)
ON_BN_CLICKED(IDC_BUTTON16,OnButtonEqual)
ON_BN_CLICKED(IDC_BUTTON13,OnButtonChu)
ON_BN_CLICKED(IDC_BUTTON12,OnButtonMul)
ON_BN_CLICKED(IDC_BUTTON11,OnButtonSub)
ON_BN_CLICKED(IDC_BUTTON10,OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON17,OnButtondelet)
ON_BN_CLICKED(IDC_BUTTON18,OnButtonclear)
ON_BN_CLICKED(IDC_BUTTON19,OnButtonkaifang)
ON_BN_CLICKED(IDC_BUTTON20,OnButtonziranduishu)
ON_BN_CLICKED(IDC_BUTTON21,OnButtonchangyongduishu)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//CJisuanqiDlgmessagehandlers
BOOLCJisuanqiDlg:
:
OnInitDialog()//初始化变量
{
CDialog:
:
OnInitDialog();
//Add"About..."menuitemtosystemmenu.
//IDM_ABOUTBOXmustbeinthesystemcommandrange.
ASSERT((IDM_ABOUTBOX&0xFFF0)==IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX<0xF000);
CMenu*pSysMenu=GetSystemMenu(FALSE);
if(pSysMenu!
=NULL)
{
CStringstrAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if(!
strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);
}
}
//Settheiconforthisdialog.Theframeworkdoesthisautomatically
//whentheapplication'smainwindowisnotadialog
SetIcon(m_hIcon,TRUE);//Setbigicon
SetIcon(m_hIcon,FALSE);//Setsmallicon
//TODO:
Addextrainitializationhere
t=true;
j=true;
i=10;
p=0;
q=0;
m_num=0;
m_lnum=0;
returnTRUE;//returnTRUEunlessyousetthefocustoacontrol
}
voidCJisuanqiDlg:
:
OnSysCommand(UINTnID,LPARAMlParam)
{
if((nID&0xFFF0)==IDM_ABOUTBOX)
{
CAboutDlgdlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog:
:
OnSysCommand(nID,lParam);
}
}
//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow
//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,
//thisisautomaticallydoneforyoubytheframework.
voidCJisuanqiDlg:
:
OnPaint()
{
if(IsIconic())
{
CPaintDCdc(this);//devicecontextforpainting
SendMessage(WM_ICONERASEBKGND,(WPARAM)dc.GetSafeHdc(),0);
//Centericoninclientrectangle
intcxIcon=GetSystemMetrics(SM_CXICON);
intcyIcon=GetSystemMetrics(SM_CYICON);
CRectrect;
GetClientRect(&rect);
intx=(rect.Width()-cxIcon+1)/2;
inty=(rect.Height()-cyIcon+1)/2;
//Drawtheicon
dc.DrawIcon(x,y,m_hIcon);
}
else
{
CDialog:
:
OnPaint();
}
}
//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags
//theminimizedwindow.
HCURSORCJisuanqiDlg:
:
OnQueryDragIcon()
{
return(HCURSOR)m_hIcon;
}
voidCJisuanqiDlg:
:
OnButton1()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+1;
UpdateData(FALSE);
}
else
{
m_num=m_num+1.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton2()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+2;
UpdateData(FALSE);
}
else
{
m_num=m_num+2.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton3()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+3;
UpdateData(FALSE);
}
else
{
m_num=m_num+3.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton4()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+4;
UpdateData(FALSE);
}
else
{
m_num=m_num+4.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton5()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+5;
UpdateData(FALSE);
}
else
{
m_num=m_num+5.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton6()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+6;
UpdateData(FALSE);
}
else
{
m_num=m_num+6.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton7()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+7;
UpdateData(FALSE);
}
else
{
m_num=m_num+7.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton8()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+8;
UpdateData(FALSE);
}
else
{
m_num=m_num+8.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton9()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
if(t)
{
m_num=m_num*10+9;
UpdateData(FALSE);
}
else
{
m_num=m_num+9.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButton0()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
//UpdateData();
if(t)
{
m_num=m_num*10+0;
UpdateData(FALSE);
}
else
{
m_num=m_num+0.0/i;
i*=10;
UpdateData(FALSE);
}
}
voidCJisuanqiDlg:
:
OnButtonPoint()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
inti=10;
t=false;
}
voidCJisuanqiDlg:
:
OnButtonEqual()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
switch(r)
{
case'+':
{
m_num=m_num+m_lnum;
UpdateData(FALSE);
break;
}
case'-':
{
m_num=m_snum-m_num;
UpdateData(FALSE);
break;
}
case'*':
{
m_num=m_mnum*m_num;
UpdateData(FALSE);
break;
}
case'/':
{
if(m_num==0)
{
MessageBox("除数不能是0!
");
}
else
{
m_num=m_cnum/m_num;
UpdateData(FALSE);
break;
}
}
}
t=true;
}
voidCJisuanqiDlg:
:
OnButtonMul()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
r='*';
t=true;
m_mnum=m_num;
m_num=0;
UpdateData(FALSE);
}
voidCJisuanqiDlg:
:
OnButtonChu()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
r='/';
t=true;
i=10;
m_cnum=m_num;
m_num=0;
UpdateData(FALSE);
}
voidCJisuanqiDlg:
:
OnButtonSub()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
r='-';
i=10;
t=true;
if(j)
{
m_snum=m_num;
}
else
{
p=0;
adda[p]=m_num;
p++;
for(q=0;q<=p;q++)
{
m_lnum=m_lnum+adda[q];
q++;
}
m_num=m_lnum;
UpdateData(FALSE);
m_num=0;
m_snum=m_lnum;
}
m_num=0;
}
voidCJisuanqiDlg:
:
OnButtonAdd()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
r='+';
t=true;
j=false;
i=10;
p=0;
adda[p]=m_num;
p++;
for(q=0;q<=p;q++)
{
m_lnum=m_lnum+adda[q];
q++;
}
m_num=m_lnum;
UpdateData(FALSE);
m_num=0;
}
voidCJisuanqiDlg:
:
OnButtondelet()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
intp;
p=m_num/10;
m_num=p;
UpdateData(FALSE);
}
voidCJisuanqiDlg:
:
OnButtonclear()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
t=true;
i=10;
j=true;
m_num=0;
m_lnum=0;
UpdateData(FALSE);
}
voidCJisuanqiDlg:
:
OnButtonkaifang()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
m_num=sqrt(m_num);
UpdateData(FALSE);
}
voidCJisuanqiDlg:
:
OnButtonziranduishu()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
m_num=log(m_num);
UpdateData(FALSE);
}
voidCJisuanqiDlg:
:
OnButtonchangyongduishu()
{
//TODO:
Addyourcontrolnotificationhandlercodehere
m_num=log10(m_num);
UpdateData(FALSE);
}
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 程序 源代码
![提示](https://static.bdocx.com/images/bang_tan.gif)