模擬計算器(MFC)實現

2021-04-07 08:27:38 字數 1655 閱讀 9662

忙了一天終於搞定了。

以下為演算法類封裝

//caldlg.cpp : implementation file

////

author: baker

//email:[email protected]

//course designing for data structures and program design in c++

//time:16/5/2006

/**/

/*a simulant calculator

description: requiring design a simulant calculator ,which could take operations such as +,-,*,/ ,( ),or functon sqr ,abs

condition:inputted expression can limit into int type.therefore ,you must check the expression for exactness.if the errors

take place ,the program would give an alarm.

*/

class

compute

... ;

void

compute::init(

string

&s)     

//³õê¼»¯êäèë±í´ïê½. 

...

void

compute::error(

inttag)    

//±¨´íº¯êý 

...strcpy(value,(

char*)(

const

char

*)str);}

bool

compute::is_optr(

char

c)     

//¼ì²éêäèëêç·ñôëëã·û 

...

char

compute:: precede(

char

op1,   

char

op2)   

...

double

compute::operat(

double

x,char

op,double

y)   

...return-1

;   }

void

compute::cal(

string

&s)   

...else

...}

else

...double

res;   

res=

operat(b,op,a);   

opnd.push(res);   

break

;  case'e

':

error(1);

return;}

}}

sprintf(value,  "%f

", opnd.top()); }

char

*compute::get_value(

string

va)...

模擬計算器的簡單實現

一.為什仫要實現大數運算?我們知道在數學領域中,數值的大小是沒有上限的,但是計算機中,由於字長的限制,計算機所能表示的範圍是有限的,當我們在實際的應用中進行大量的資料處理的時候,會發現參與運算的數往往超過計算機的基本資料型別的表示範圍。假設一個資料的型別是long long那仫它最多可表示的資料是8...

簡單計算器模擬

雖然打個簡單計算器不算難事,但是模擬始終算一關,不能忽視基礎。本程式不適用以下情況 表示式中帶空格 表示式中帶括號 僅能進行四則運算,結果限制在int型 include using namespace std intlevel char x intcalculate string s if q1.e...

MFC之簡單計算器

1 介面 2 變數 combobox的變數型別是ccombobox型別,三個輸入框是double型別 它的type是drop list 3 1 初始化combobox bool ccalculaterdlg oninitdialog 這個方法是用來初始化控制元件的 m comboweb.setcur...

實現計算器

dim boldot as boolean dim dblacc1,dblacc2 as double dim dblacc3 as double 10 dim strop as string private sub add num byval intnumber as integer if bol...

MFC計算器專案 日期計算模組

計算器日期計算模組 執行效果圖參見計算器專案綜述 主要實現兩個功能 與windows計算器中的日期計算功能一致 1.給定兩個時間,計算日期差 2.給出基礎時間和時間差,計算目標時間 該模組開發文件截圖 核心 如下 mydlg 1.cpp implementation file include std...