• 周易算卦流程c++实现


    代码

    #include
    using namespace std;
    #include
    #include
    #include
    #include
    
    int huaYiXiangLiang(int all, int& left)
    {
    	Sleep(3000);
    	srand(time(0));
    	left = rand() % all + 1;
    	while (true) {
    		if (left >= all-1 || left <= 1)
    		{
    			left = rand() % all + 1;
    		}
    		else break;
    	}
    	return all - left;
    }
    
    int main()
    {
    	vector<int> liuYao;
    
    	for (int yao = 1; yao <= 6; ++yao) {
    		vector<int> gua;
    		int daYanZhiShu = 55;
    		int qiYong = 55 - 6;
    
    		for (int step = 1; step <= 3; ++step) {
    			#if 1 分而为二以象两
    			int left = 0;
    			int right = huaYiXiangLiang(qiYong, left);
    			cout << "left: " << left << ", right: " << right << endl;
    			#endif
    
    			int tmpRight = right;
    #if 1 挂一以象三
    			tmpRight -= 1;
    			gua.push_back(1);
    			cout << "tmpRight: " << tmpRight << endl;
    #endif
    
    #if 1 揲之以四以象四时
    			while (tmpRight > 4)
    			{
    				tmpRight -= 4;
    			}
    			cout << "tmpRight: " << tmpRight << endl;
    #endif
    
    #if 1 归奇于扐以象闰
    			if (tmpRight == 4) {
    				left -= 4;
    				tmpRight -= 4;
    				gua.push_back(8);
    			}
    			else if (tmpRight < 4)
    			{
    				left -= (4 - tmpRight);
    				tmpRight = 0;
    				gua.push_back(4);
    			}
    			cout << "left: " << left << endl;
    #endif
    
    			for (int i = 0; i < gua.size(); ++i)
    			{
    				qiYong -= gua[i];
    			}
    			gua.clear();
    
    			std::cout << "new qiYong: " << qiYong << endl;
    
    			if (step != 3) {
    				// 放回1
    				qiYong += 1;
    			}
    
    		}
    		liuYao.push_back( qiYong / 4 );
    		cout << yao << " complete.\r\n";
    	}
    	for (int yao : liuYao) {
    		cout << yao << " ";
    	}
    	cout << endl;
    
    	return 0;
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93

    在这里插入图片描述
    六爻分别为:少阴、少阴、少阳、老阳、老阳、少阴

  • 相关阅读:
    【全民Python】PIP模块的安装,Pyinstaller模块安装,导出exe文件
    springboot整合
    莱特兄弟的家庭教育
    【docker】Dockerfile
    Qt通过ODBC连接openGauss数据库
    【1++的C++进阶】之emplace详解
    微信小程序封装的请求事件
    CSS实现竖向步骤条
    算法基础之差分和前缀和
    java实现权重随机获取值或对象
  • 原文地址:https://blog.csdn.net/sdhdsf132452/article/details/132917591