vc课程设计打印文档格式.docx

上传人:b****6 文档编号:16269232 上传时间:2022-11-22 格式:DOCX 页数:19 大小:148.02KB
下载 相关 举报
vc课程设计打印文档格式.docx_第1页
第1页 / 共19页
vc课程设计打印文档格式.docx_第2页
第2页 / 共19页
vc课程设计打印文档格式.docx_第3页
第3页 / 共19页
vc课程设计打印文档格式.docx_第4页
第4页 / 共19页
vc课程设计打印文档格式.docx_第5页
第5页 / 共19页
点击查看更多>>
下载资源
资源描述

vc课程设计打印文档格式.docx

《vc课程设计打印文档格式.docx》由会员分享,可在线阅读,更多相关《vc课程设计打印文档格式.docx(19页珍藏版)》请在冰豆网上搜索。

vc课程设计打印文档格式.docx

e=2.718281828459;

lnisthenaturallogarithm,inmath,ln(x)istobaseelogx

Sin--AonedgeandbevelanglethancalledangleAsine,denotedassinA,sinA=angleAtotheedge/hypotenuse.

Cos--thecosinetheoremisrevealedinthetriangularrelationshipbetweenthecornersofanimportanttheorem,itcanbedirectlyusedtosolveaclassofknowntriangletwosidesandangleofthirdorthreeedgeangleisknownfortheproblems,ifthecosinetheoremtobedeformedandappropriatelymovedtootherknowledge,itismoreconvenienttouse,flexible.

Tan--thetangentfunctionisarighttriangle,theedgeandtheadjacentedgeoftheratio.

N!

--thisisthefactorialofmathematics.

计算器按钮上的符号,例如:

PI就是π的意思,取π=3.1415926;

e=2.718281828459;

ln就是自然对数,在数学中ln(x)是以e为底的x的对数

sin——角A的对边与斜边的比叫做角A的正弦,记作sinA,即sinA=角A的对边/斜边。

cos——余弦定理是揭示三角形边角关系的重要定理,直接运用它可解决一类已知三角形两边及夹角求第三边或者是已知三个边求角的问题,若对余弦定理加以变形并适当移于其它知识,则使用起来更为方便、灵活。

tan——正切函数是直角三角形中,对边与邻边的比值。

n!

——这个是数学中的阶乘。

计算器上的按钮表示计算器上的运算符号,代码中有实现该功能所用到的函数,这些函数中有从math.h中调用得到的,也有自己编写的。

Calculatorbuttonsonsaidcalculatoroperationalsymbol,codehastoachievethefunctionoftheuseoffunction,thesefunctionsarecalledfrommath.hobtained,alsohavetheirownwritten.

Button

Callfunction(调用的函数)

%

fmod(num1,num2)

sin

doublesin(doublex)

cos

doublecos(doublex)

tan

doubletan(doublex)

/

doublemodf(double,double*)

arcsin

doubleasin(doublex)

arccos

doubleacos(doublex)

arctan

doubleatan(doublex)

sqrt

doublesqrt(doublex)

 

Detailedcodecalculatordesign

计算器的详细代码设计

1.Buttonoperationpartofdigitaldesigncode(按钮上运算数字部分的代码设计)

Thefollowingcodeusedtodisplaythebuttononthecontent,equivalenttoabuttononthedisplaydefinition,whentheinputnumber,calculatorbycallingtheinternalfunctiontorefreshthedata,whenpressingthenumberkeys,constant,adecimalpointkey,thedatadisplayedintheeditbox,againwithinternalfunctiontorefreshdatatransfer.

以下代码用于显示按钮上的内容,相当于按钮的定义,当在显示器上输入数字后,计算器通过调用内部函数来刷新数据,当按下数字键、常数、小数点键时,就把该数据显示在编辑框内,再次调用内部函数来刷新数据。

//数字0

voidCCalculatebDlg:

:

On0()

{

//TODO:

Addyourcontrolnotificationhandlercodehere

UpdateData();

m_lecture+="

0"

;

UpdateData(FALSE);

}

//数字1

On1()

1"

//数字2

On2()

UpdateData();

2"

//数字3

On3()

3"

//数字4

On4()

4"

//数字5

On5()

5"

//数字6

On6()

6"

//数字7

On7()

7"

//数字8

On8()

8"

//数字9

On9()

9"

//小数点

Onf()

."

//pi的值

Onpi()

m_lecture+="

3.1415926"

2.计算器上一般运算符号的代码设计

Thisarithmeticforadd,subtract,multiplyanddivideanddemand,calculatorrefreshdataafterthefirstinputdataisassignedtothevariableA1,willbeusedtoselecttheoperationoftheswitchfunctioninthecasecorrespondstothenumberofvaluem,easytocalloperationfunctioncomputation.ThenthesecondinputdatatoA2,thenA1,A2fromthestringtypedoublecharacter,thisisaveryimportantstep,thecomputerfunctionsasthecontentonadisplayscreenfromthestringconversiontocomputerexecutabledoubleprecisioncharacter,throughthecodetoachievethecalculatorcalculationfunction.Finally,fortheadditionandsubtractionoperationsofx^yA1andA2directlybetweentheoperation,fordivisiontojudgewhetherthedivisoriszero,ifzerowerewarned,ifnotzero,thenadivisionoperation.Switchusedinprogramming,suchasClanguagesitisoftenusedwithCase.,isajudgeselectioncode.Itsfunctionistocontrolthebusinessprocessflow.Thisdesignisthegeneraloperationalsymbolselectioncalculator.此部分运算为加减乘除及求余,计算器刷新数据后把第一次输入的数据赋给变量a1,将用于选择运算的switch函数中的case对应的编号值赋予m,便于调用运算函数进行运算。

然后把第二次输入的数据传给a2,然后将a1、a2由字符串型转换成双精度字符型,这是很重要的一步,计算机功能的实现即为将显示屏上的内容从字符串转换为计算机可执行的双精度字符型,通过代码实现计算器的计算功能。

最后,对于加减乘x^y运算直接进行a1与a2之间的运算,对于除法先进行判断除数是否为零,若为零就进行警告,若不为零,则进行除法运算。

Switch用在编程中,如C语言中它经常跟Case一起使用,是一个判断选择代码。

其功能就是控制业务流程流转的。

此设计中是对计算器一般运算符号的选择。

Ona()

a1=m_lecture;

m_lecture+="

+"

m=1;

Onb()

-"

m=2;

Onc()

*"

m=3;

Ond()

/"

m=4;

Onqy()

%"

m=5;

Onequal()

a2=m_lecture;

doublenum1=atof(a1);

doublenum2=atof(a2);

doublenum3;

switch(m)

{

case1:

num3=num1+num2;

m_lecture.Format(_T("

%lf"

),num3);

m_lecture=Delling(m_lecture);

break;

case2:

num3=num1-num2;

case3:

num3=num1*num2;

case4:

if(num2==0)

{

MessageBox("

除数不能为0,请重新输入除数!

"

);

m_lecture="

}

else

num3=num1/num2;

m_lecture.Format(_T("

m_lecture=Delling(m_lecture);

case5:

"

警告"

MB_OK);

doublenum3=fmod(num1,num2);

//在math.h中调用fmod进行计算器求余功能的实现

default:

break;

}

UpdateData(FALSE);

3.计算器上特殊运算符的代码设计

Sin,cos,Tan,arcsin,arccos,arctandirectlyfrommath.hcallingfunctioncouldachieveitsoperationalfunctionforcotoperation,thedirectuseofCOSdividedbysinfor.Thefactorialn!

Operationbyforcycletoachieve,thefactorialforcycletoachieve,forcycleisacircle.Itsgeneralform:

for(<

>

<

expression>

initialize;

condition;

incrementstatement<

initializationisalwaysanassignmentstatement,itisusedtogivetheloopcontrolvariableinitialization;

conditionalexpressionisanexpression,itisdecidingwhentoexitaloop;

incrementaldefinitionforloopcontrolvariableforeachcycletimebywhatmeanschanges.Thethreepartby"

separate.

sin,cos,tan,arcsin,arccos,arctan直接从math.h中调用函数就可以实现其运算功能,对于cot运算直接用cos除以sin求的。

阶乘n!

的运算时通过for循环来实现的,此处的阶乘用for循环来实现,for循环是开界的。

它的一般形式为:

for(<

初始化>

条件表达式>

增量>

)语句;

初始化总是一个赋值语句,它用来给循环控制变量赋初值;

条件表达式是一个关系表达式,它决定什么时候退出循环;

增量定义循环控制变量每循环一次后按什么方式变化。

这三个部分之间用"

分开。

Onsin()

doublenum2=sin(PI/180*num1);

m_lecture.Format(_T("

),num2);

Oncos()

doublenum2=cos(PI/180*num1);

Ontan()

doublenum

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

当前位置:首页 > 经管营销 > 公共行政管理

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

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