資源簡介
計算24點的C++源代碼,里面用2種方式進行了10以內數字任取4個數算24點。
第一種是用遞歸的方式;
第二種方式采用后綴表達式。
更詳細的思路說明及細節介紹請參考我的文章:
http://blog.csdn.net/sun2043430/article/details/8739042
代碼片段和文件信息
//?Calc24.cpp?:?Defines?the?entry?point?for?the?console?application.
//
#include?“stdafx.h“
#include?
#include?
#include?
#include?
#include?“Postfixexpression.h“
char?g_op[]?=?{‘+‘?‘-‘?‘*‘?‘/‘};
double?g_Fstack[20];
double?g_Sstack[20];
char??g_Cstack[20];
int?g_n1?=?0;
int?g_n2?=?0;
int?g_Total?=?0;
bool?g_bOnlyGetOne?=?true;
double?g_fArray[4];
double?Operation(double?f1?double?f2?char?c)
{
????double?f;
????if?(‘/‘?==?c?&&?fabs(f2)?0.0001)
????{
????????assert(0);
????}
????switch?(c)
????{
????case?‘+‘:
????????f?=?f1?+?f2;
???? break;
????case?‘-‘:
????????f?=?f1?-?f2;
???? break;
????case?‘*‘:
????????f?=?f1?*?f2;
???? break;
????case?‘/‘:
????????f?=?f1?/?f2;
???? break;
????}
????g_Fstack[g_
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????5818??2013-04-05?12:35??Calc24.cpp
?????文件?????????877??2013-04-05?16:07??Calc24.sln
?????文件????????8192??2013-04-05?16:11??Calc24.suo
?????文件????????4657??2013-04-05?10:03??Calc24.vcproj
?????文件????????6700??2013-04-05?10:06??Postfixex
?????文件??????????75??2013-04-05?10:03??Postfixex
?????目錄???????????0??2013-04-05?16:11??Release\
?????文件???????16896??2013-04-05?16:10??Release\Calc24.exe
?????文件?????????293??2013-04-02?19:46??stdafx.cpp
?????文件?????????320??2013-04-02?19:46??stdafx.h
?????文件?????????765??2013-04-02?19:46??targetver.h
- 上一篇:施密特正交化C語言程序
- 下一篇:黑白棋c++ 源代碼
評論
共有 條評論