資源簡介
表達式求值的經典算法(逆波蘭)
數據表達式類
1. 可完成中綴表達式式到后綴表達式的轉換
2. 后綴表達式求值.
代碼片段和文件信息
//?Mathematical.cpp:?implementation?of?the?CMathematical?class.
//
//////////////////////////////////////////////////////////////////////
#include?“StdAfx.h“
#include?“stdio.h“
#include?“Mathematical.h“
#pragma?warning(???disable???:???4786???)?
//////////////////////////////////////////////////////////////////////
//?Construction/Destruction
//////////////////////////////////////////////////////////////////////
CMathematical::CMathematical()
{
????m_pData?=?NULL;
????m_iDataLength?=?0;???
}
CMathematical::~CMathematical()
{
}
/*
轉換過程包括用下面的算法讀入中綴表達式的操作數、操作符和括號:
初始化一個空堆棧,將結果字符串變量置空。?
從左到右讀入中綴表達式,每次一個字符。?
如果字符是操作數,將它添加到結果字符串。?
如果字符是個操作符,彈出(pop)操作符,直至遇見開括號(opening?parenthesis)、優先級較低的操作符或者同一優先級的右結合符號。把這個操作符壓入(push)堆棧。?
如果字符是個開括號,把它壓入堆棧。?
如果字符是個閉括號(closing
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????32064??2009-03-28?10:16??MathematicalTest\Mathematical.cpp
?????文件???????7686??2009-03-28?10:17??MathematicalTest\Mathematical.h
?????文件????????754??2009-03-28?10:19??MathematicalTest\MathematicalTest.cpp
?????文件???????4796??2009-03-28?10:17??MathematicalTest\MathematicalTest.dsp
?????文件????????555??2009-03-28?10:17??MathematicalTest\MathematicalTest.dsw
?????文件??????54784??2009-03-28?10:19??MathematicalTest\MathematicalTest.opt
?????文件???????1654??2009-03-28?10:17??MathematicalTest\MathematicalTest.plg
?????文件???????1268??2009-03-28?09:42??MathematicalTest\ReadMe.txt
?????文件????????303??2009-03-28?09:42??MathematicalTest\StdAfx.cpp
?????文件????????667??2009-03-28?09:42??MathematicalTest\StdAfx.h
?????目錄??????????0??2009-03-28?10:19??MathematicalTest
-----------?---------??----------?-----??----
???????????????104531????????????????????11
- 上一篇:3層bp神經網絡實現
- 下一篇:平方根法(Cholesky分解法)解線性方程組
評論
共有 條評論