计算器ppt演示文稿._第1页
计算器ppt演示文稿._第2页
计算器ppt演示文稿._第3页
计算器ppt演示文稿._第4页
计算器ppt演示文稿._第5页
已阅读5页,还剩16页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、杨柔杨柔YangRou付丽平付丽平FuLIPing刘计云刘计云LiuJiYun1 12 23 3姚婷姚婷YaoTing标题1标题2标题3 计算器的代码编程计算器的代码编程计算器的功能介绍计算器的界面设计1 12 23 31 12 2付丽萍功能介绍杨柔界面设计姚婷刘计云代码编程 引出一个数学类库头文件#include math.h#ifdef _DEBUG#define new DEBUG_NEW#undef THIS_FILEstatic char THIS_FILE = _FILE_;#endif/预定义两个常数变量PI和e#define PI 3.1415926#define e 2.71

2、8281828459/定义字符串类型的两个变量a1与a2,主要用于对两次输入的数据进行缓存以便于进行计算CString a1,a2;/一个整数变量m,用于在函数Onequal中进行运算时进行运算符的选择int m=0;Set the icon for this dialog. The framework does this automaticallySet big iconSet small icon when the applications main window is not a dialog如果你添加一个尽量减少如果你添加一个尽量减少按钮到您的对话框,你将需按钮到您的对话框,你将需y代

3、码绘制图标。代码绘制图标。对对applicationsusing的的文档文档/视图模型,这是自动完成你的框架。视图模型,这是自动完成你的框架。The system calls this to obtain the cursor to display while the user dragsvoid CCalculatebDlg:OnPaint() if (IsIconic()CPaintDC dc(this); / device context for painting SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);/

4、Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);Contentwelcome to use these PowerPoint templates, New Content design, 10 years experienceint cyIcon = GetSystemMetrics(SM_CYICON);CRect rect;GetClientRect(&rect);int x = (rect.Width() - cxIcon + 1) / 2;int y = (rect.Height()

5、 - cyIcon + 1) / 2;/ Draw the icondc.DrawIcon(x, y, m_hIcon);elseCDialog:OnPaint();通过该操作可以把计算器内部通过通过该操作可以把计算器内部通过a1、a2缓存的值以缓存的值以及界面显示的值全部清空。及界面显示的值全部清空。void CCalculatebDlg:Once() / TODO: Add your control notification handler code hereUpdateData();/m_lecture = ;a1 = ;a2 = ;UpdateData(FALSE);void CCal

6、culatebDlg:Ondel()/ TODO: Add your control notification handler code hereUpdateData();int length =m_lecture.GetLength();/通过调用内部函数m_edit.GetLength()来获取显示其上的长度并将值赋给变流量length,length-;/把length值减一m_lecture = m_lecture.Left(length)/从左侧起获取length位的数据交给显示框显示UpdateData(FALSE);Content/加减乘除和求余加减乘除和求余void CCalcu

7、latebDlg:Ona() UpdateData();a1=m_lecture;m_lecture+=+;m=1;UpdateData(FALSE); void CCalculatebDlg:Onb() / TODO: Add your control notification handler code here UpdateData();a1=m_lecture;m_lecture+=-;m=2;UpdateData(FALSE); void CCalculatebDlg:Oncot() / TODO: Add your control notification handler code

8、hereUpdateData();a1=m_lecture;double num1=atof(a1);double num2=cos(PI/180*num1)/sin(PI/180*num1);m_lecture.Format(_T(%lf), num2);UpdateData(FALSE);void CCalculatebDlg:Onc() / TODO: Add your control notification handler code hereUpdateData();a1=m_lecture;m_lecture+=*;m=3;UpdateData(FALSE)void CCalcul

9、atebDlg:Onarcsin() / TODO: Add your control notification handler code herea1=m_lecture;double num1=atof(a1);double num2= asin (num1)*(180/PI);m_lecture.Format(_T(%lf), num2);UpdateData(FALSE);void CCalculatebDlg:Onarccos() / TODO: Add your control notification handler code herea1=m_lecture;double nu

10、m1=atof(a1);double num2= acos (num1)*(180/PI);m_lecture.Format(_T(%lf), num2);UpdateData(FALSE);void CCalculatebDlg:Onarctan() / TODO: Add your control notification handler code herea1=m_lecture;double num1=atof(a1);double num2= atan (num1)*(180/PI);m_lecture.Format(_T(%lf), num2);UpdateData(FALSE);

11、1 12 23 32 23 3123首先,将输入的值赋给编辑框,然后将a1转换成双精度的书num1231/首先把输入的数据传给r1,然后将r1由字符串型转换成双精度字符型num1/(First turn on the second input data to r1, then r1from the string type into double precision character type num1)/最后,三个或两个num1相乘即可/x3运算oid CCalculatebDlg:Onpow() / TODO: Add your control notification handler c

12、ode herea1=m_lecture;double num1=atof(a1);double num2= num1*num1;m_lecture.Format(_T(%lf), num2);UpdateData(FALSE);Contentvoid CCalculatebDlg:Ondaoshu() / TODO: Add your control notification handler code here a1=m_lecture;double num1=atof(a1); double num2= 1/num1 ; m_lecture.Format(_T(%lf), num2);Up

13、dateData(FALSE);Contentvoid CCalculatebDlg:Onjiecheng() / TODO: Add your control notification handler code hereUpdateData();a1=m_lecture;double n=atof(a1); doublej=1,num2=1; for(j=1;j=n;j+) num2=j*num2; m_lecture.Format(_T(%lf), num2);UpdateData(FALSE);Contentvoid CCalculatebDlg:Onsqrt() / TODO: Add your control notification handler code hereUpdateData

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论