```
// LeftOrRightCon21A0802.cpp : 此文件包含 "main" 函數的完整C++程序。
//一、先設置掉落 于N(north)的次數 為某個常數,比如 100times,1000次,10000times次,1000000times等;
//二、設置“格子數”的數量 為 自變量 X (x 屬于 1~ N), N 逐漸增大(且從2~ loop to Infinity 從2循環到無窮;
//三、求 F(x) == y Y 為 回到 Zero (the Times of come back to Zero's) Times;
//四、最后觀察 Y 與 X 的關系, 推斷構造 得出 F(x)函數 …Asume F(x)……
#include <iostream>
#define FailTime10s 1000000
int main()
{
//----------------------------------
int X_int = 0; //從 from 0,1 to Infinity(從1 到 無窮)…
unsigned long int Y_comeZeroSuccessTimes = 0; //因變量為 成功回到 Zero點的次數
int count_NorthFail = 0; //此變量用于計數,看是否達到 掉落于N點的次數,達到 FailTime10s 1000000 次 則 輸出 x,Y的 List 值
bool tmpbool = 0;
// int failTimes = 0;
for (int NN1=1;true;++NN1) {//forNN1_110//NN1 for1 loop to Infinity(WuQiong無窮)
//
Start110:
X_int = 1; //leave Zero to 1;
// do {//do2200while
//
Start2200:
tmpbool = rand() % 2;
if (0 == tmpbool) { //if110
--X_int;
if (X_int < 1) {//if220
++Y_comeZeroSuccessTimes;
//X_int = 1;
goto Start110; //go back Zero Success One time!
}//if220
goto Start2200; // living and continue walking...this Else is RongYu冗余
}//if110
else if (1 == tmpbool) { //if1100
++X_int;
if ( X_int >= NN1) {//if2200
++count_NorthFail;
if ( count_NorthFail >= FailTime10s ) //if3300 //超過 FailTime10s //超過10次/100次/1000/10000/100000等次數 的掉落 N (North)Fail
{
goto GoOut_andPrint990; //For Loop (for110) Finished!
// 此處就是唯一出口
}//if3300
goto Start110; //go N(north) Fail One time!
}//if2200
goto Start2200; //living and continue walking...this Else is RongYu冗余
}//if1100
//
X_int = 1;
goto Start2200; //loop
//這里隱含一條:
// if(0<X_int && X_int<NN1) {goto Start2200;} //因為 (0<X_int && X_int<NN1) ,此時,一定成立的
// } while (true);//do2200while
//
GoOut_andPrint990:
std::cout << "N=" << NN1 << "時:";
//std::cout << NN1;
std::cout << " Nfail:" << count_NorthFail;
std::cout << " zero:" << Y_comeZeroSuccessTimes;
std::cout << std::endl;
count_NorthFail = 0;
Y_comeZeroSuccessTimes= 0;
}//forNN1_110
//while (true);//do110while(true
//==================================
}//main()
```
The Result( 運行結果):
N=2時: Nfail:1000000 zero:999695
N=3時: Nfail:1000000 zero:2000181
N=4時: Nfail:1000000 zero:2999937
N=5時: Nfail:1000000 zero:4000302
N=6時: Nfail:1000000 zero:4999780
N=7時: Nfail:1000000 zero:6000282
N=8時: Nfail:1000000 zero:6999794
N=9時: Nfail:1000000 zero:7999785
N=10時: Nfail:1000000 zero:9000442
N=11時: Nfail:1000000 zero:9999520
N=12時: Nfail:1000000 zero:11000037
……
Omitted below……
(省略后面運行結果)
**運行結果解釋如下:**
當 N=2時, 則表示共有兩個格子……;
此時,掉落于N的 次數 與 回到 Zero的次數 約等!
當 N== 3 掉落于N的次數 與 回到 Zero的次數 呈現 1比2;
當 N==4 掉落 次數 與 回到0 的次數 比率為: 1:3;
以此類推, 推測結果為:
掉落 于 N (North) 的概率 為 1/N( N分之一---- N為格子 數 )。
2021年8月19 Terry