91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

實現了24點游戲的算法,只需輸入4個數字就可以打印有多少種算出24點的方法

資源截圖

代碼片段和文件信息

//////////////////////////////////////////////////////////////////////////

//?編程題目:?計算?24?點

//?編譯環境:?Visual?C++?6.0

//?程序設計:?廖增祥

//////////////////////////////////////////////////////////////////////////

#include?



//////////////////////////////////////////////////////////////////////////

//?Process:?計算處理過程?遞歸函數

//????????????????????????result????????[in]????????????????當前計算結果

//????????????????????????a????????????????[in]????????????????原始計算數據

//????????????????????????fuhao????????[in?out]????????要保存的符號數組

//????????????????????????nIndex????????[in]????????????????當前遞歸所在層[0?-?2]

int?Process(int?result?int?*a?char?*fuhao?int?nIndex)

{

????????int?temp;



????????//?1.?計算加法

????????temp?=?result?+?a[nIndex?+?1];

????????fuhao[nIndex]?=?‘+‘;

????????if(temp?==?24?&&?nIndex?==?2)

????????????????return?1;



????????if(nIndex?
????????????????if(Process(temp?a?fuhao?nIndex?+?1))

????????????????????????return?1;

????????

????????//?2.?計算減法

????????temp?=?result?-?a[nIndex?+?1];

????????fuhao[nIndex]?=?‘-‘;

????????if(temp?==?24?&&?nIndex?==?2)

????????????????return?1;

????????if(nIndex?
????????????????if(Process(temp?a?fuhao?nIndex?+?1))

????????????????????????return?1;

????????

????????//?3.?計算乘法

????????temp?=?result?*?a[nIndex?+?1];

????????fuhao[nIndex]?=?‘*‘;



????????if(nIndex?!=?0)

????????{

????????????????//?重新計算?temp?的值

????????????????if(fuhao[nIndex?-?1]?==?‘+‘)

????????????????{

????????????????????????temp?=?result?-?a[nIndex]?+?a[nIndex]?*?a[nIndex?+?1];

????????????????}

????????????????else?if(nIndex?==?2?&&?fuhao[0]?==?‘+‘?&&?(fuhao[1]?==?‘*‘?||?fuhao[1]?==?‘/‘))

????????????????{

????????????????????????temp?=?result?-?(result?-?a[0])?+?(result?-?a[0])?*?a[nIndex?+?1];

????????????????}



????????????????else?if(fuhao[nIndex?-?1]?==?‘-‘)

????????????????{

????????????????????????temp?=?result?+?a[nIndex]?-?a[nIndex]?*?a[nIndex?+?1];

????????????????}

????????????????else?if(nIndex?==?2?&&?fuhao[0]?==?‘-‘?&&?(fuhao[1]?==?‘*‘?||?fuhao[1]?==?‘/‘))

????????????????{

????????????????????????temp?=?result?+?(result?-?a[0])?-?(result?-?a[0])?*?a[nIndex?+?1];

????????????????}

????????}



????????if(temp?==?24?&&?nIndex?==?2)

????????????????return?1;



????????if(nIndex?
????????????????if(Process(temp?a?fuhao?nIndex?+?1))

????????????????????????return?1;

????????

????????//?4.?計算除法

????????int?bContinue?=?1;

????????if(a[nIndex?+?1]?==?0)

????????????????return?0;

????????temp?=?result?/?a[nIndex?+?1];

????????fuhao[nIndex]?=?‘/‘;



????????if(nIndex?!=?0)

????????{

????????????????if(fuhao[nIndex?-?1]?==?‘+‘)

????????????????{

????????????????????????//?重新計算?temp?的值

????????????????????????if(a[nIndex?+?1]?&&?a[nIndex]?%?a[nIndex?+?1]?==?0)

???????????????????

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2013-11-08?01:56??24point\
?????文件????????5514??2013-11-07?01:50??24point\24point.cpp
?????文件????????4296??2013-11-07?02:06??24point\24point.dsp
?????文件?????????520??2013-11-06?23:13??24point\24point.dsw
?????文件???????41984??2013-11-08?01:55??24point\24point.ncb
?????文件???????48640??2013-11-08?01:55??24point\24point.opt
?????文件?????????893??2013-11-07?01:50??24point\24point.plg
?????目錄???????????0??2013-11-07?01:50??24point\Debug\
?????文件??????184389??2013-11-07?01:50??24point\Debug\24point.exe
?????文件??????215180??2013-11-07?01:50??24point\Debug\24point.ilk
?????文件????????5710??2013-11-07?01:50??24point\Debug\24point.obj
?????文件??????203736??2013-11-06?23:21??24point\Debug\24point.pch
?????文件??????451584??2013-11-07?01:50??24point\Debug\24point.pdb
?????文件???????33792??2013-11-07?01:50??24point\Debug\vc60.idb
?????文件???????45056??2013-11-07?01:50??24point\Debug\vc60.pdb

評論

共有 條評論