💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
``` // 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