c++高级计算器报告Word下载.docx

上传人:b****6 文档编号:18991880 上传时间:2023-01-02 格式:DOCX 页数:21 大小:172.16KB
下载 相关 举报
c++高级计算器报告Word下载.docx_第1页
第1页 / 共21页
c++高级计算器报告Word下载.docx_第2页
第2页 / 共21页
c++高级计算器报告Word下载.docx_第3页
第3页 / 共21页
c++高级计算器报告Word下载.docx_第4页
第4页 / 共21页
c++高级计算器报告Word下载.docx_第5页
第5页 / 共21页
点击查看更多>>
下载资源
资源描述

c++高级计算器报告Word下载.docx

《c++高级计算器报告Word下载.docx》由会员分享,可在线阅读,更多相关《c++高级计算器报告Word下载.docx(21页珍藏版)》请在冰豆网上搜索。

c++高级计算器报告Word下载.docx

_declspec(dllexport)doubleAdd(doublea,doubleb)

{returna+b;

}

_declspec(dllexport)doubleSub(doublea,doubleb)

{returna-b;

_declspec(dllexport)doubleMultiply(doublea,doubleb)

{returna*b;

_declspec(dllexport)doubleDivide(doublea,doubleb)

{returna/b;

}

(2)计算器源程序代码

#include"

stdafx.h"

asan_mfc.h"

asan_mfcDlg.h"

//#include<

String>

#ifdef_DEBUG

#definenewDEBUG_NEW

#undefTHIS_FILE

staticcharTHIS_FILE[]=__FILE__;

#endif

charoper,ch[20];

intdian=0,q=0;

CStrings1,stri;

intm=0,k=0,n=0,a=0;

//m=0输入单步运算,m=1输入算式运算

CStringtt,aa,ss;

CStringstr,num[20];

doubleaaa;

ints=0,i=0,j,www;

doublex1,x2,x;

_declspec(dllexport)doubleadd(doublea,doubleb);

_declspec(dllexport)doublesub(doublea,doubleb);

_declspec(dllexport)doublecheng(doublea,doubleb);

_declspec(dllexport)doublechu(doublea,doubleb);

/////////////////////////////////////////////////////////////////////////////

//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()

//CAsan_mfcDlgdialog

CAsan_mfcDlg:

CAsan_mfcDlg(CWnd*pParent/*=NULL*/)

:

CDialog(CAsan_mfcDlg:

IDD,pParent)

//{{AFX_DATA_INIT(CAsan_mfcDlg)

m_text=_T("

"

);

//NotethatLoadIcondoesnotrequireasubsequentDestroyIconinWin32

m_hIcon=AfxGetApp()->

LoadIcon(IDR_MAINFRAME);

voidCAsan_mfcDlg:

//{{AFX_DATA_MAP(CAsan_mfcDlg)

DDX_Text(pDX,IDC_EDIT1,m_text);

BEGIN_MESSAGE_MAP(CAsan_mfcDlg,CDialog)

//{{AFX_MSG_MAP(CAsan_mfcDlg)

ON_WM_SYSCOMMAND()

ON_WM_PAINT()

ON_WM_QUERYDRAGICON()

ON_BN_CLICKED(IDC_num1,Onnum1)

ON_BN_CLICKED(IDC_num2,Onnum2)

ON_BN_CLICKED(IDC_num3,Onnum3)

ON_BN_CLICKED(IDC_num4,Onnum4)

ON_BN_CLICKED(IDC_num5,Onnum5)

ON_BN_CLICKED(IDC_num6,Onnum6)

ON_BN_CLICKED(IDC_num7,Onnum7)

ON_BN_CLICKED(IDC_num8,Onnum8)

ON_BN_CLICKED(IDC_num9,Onnum9)

ON_BN_CLICKED(IDC_Dian,OnDian)

ON_BN_CLICKED(IDC_num0,Onnum0)

ON_BN_CLICKED(IDC_add,Onadd)

ON_BN_CLICKED(IDC_sub,Onsub)

ON_BN_CLICKED(IDC_cheng,Oncheng)

ON_BN_CLICKED(IDC_chu,Onchu)

ON_BN_CLICKED(IDC_Deng,OnDeng)

ON_BN_CLICKED(IDC_Esc1,OnEsc1)

ON_BN_CLICKED(IDC_RADIO1,OnRadio1)

ON_BN_CLICKED(IDC_RADIO2,OnRadio2)

ON_BN_CLICKED(IDC_EDIT2,OnEdit2)

ON_NOTIFY(DTN_CLOSEUP,IDC_DATETIMEPICKER1,OnCloseupDatetimepicker1)

//CAsan_mfcDlgmessagehandlers

BOOLCAsan_mfcDlg:

OnInitDialog()

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);

AppendMenu(MF_STRING,IDM_ABOUTBOX,strAboutMenu);

}

//Settheiconforthisdialog.Theframeworkdoesthisautomatically

//whentheapplication'

smainwindowisnotadialog

SetIcon(m_hIcon,TRUE);

//Setbigicon

SetIcon(m_hIcon,FALSE);

//Setsmallicon

//TODO:

Addextrainitializationhere

returnTRUE;

//returnTRUEunlessyousetthefocustoacontrol

OnSysCommand(UINTnID,LPARAMlParam)

if((nID&

0xFFF0)==IDM_ABOUTBOX)

CAboutDlgdlgAbout;

dlgAbout.DoModal();

else

CDialog:

OnSysCommand(nID,lParam);

//Ifyouaddaminimizebuttontoyourdialog,youwillneedthecodebelow

//todrawtheicon.ForMFCapplicationsusingthedocument/viewmodel,

//thisisautomaticallydoneforyoubytheframework.

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);

OnPaint();

//Thesystemcallsthistoobtainthecursortodisplaywhiletheuserdrags

//theminimizedwindow.

HCURSORCAsan_mfcDlg:

OnQueryDragIcon()

return(HCURSOR)m_hIcon;

Onnum1()

Addyourcontrolnotificationhandlercodehere

if(m==0)

s1=s1+"

1"

;

m_text=s1;

elseif(m==1)

{q=0;

num[i]=num[i]+"

m_text=m_text+"

UpdateData(false);

Onnum2()

2"

q=0;

Onnum3()

3"

Onnum4()

if(m==0)

4"

{num[i]=num[i]+"

Onnum5()

5"

{q=0;

Onnum6()

6"

Onnum7()

7"

Onnum8()

8"

Onnum9()

9"

OnDian()

{if(dian==0)

."

dian=1;

if(dian==0)

dian=1;

q=0;

Onnum0()

0"

q=0;

Onadd()

x1=atof(s1);

m_text="

+"

s1=_T("

dian=0;

oper='

+'

if(q==0){

ch[i++]='

q=1;

Onsub()

{

-"

-'

if(q==0){q=1;

Oncheng()

*"

*'

if(q==0)

{q=1;

Onchu()

/"

/'

OnDeng()

x2=atof(s1);

if((x2==0)&

&

(oper=='

))

m_text="

除数不能为零!

重新输入"

UpdateData(false);

s1=_T("

}else

switch(oper)

{

case'

x=add(x1,x2);

break;

case

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 自然科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1