13872434240
级别: 正式会员
精华主题: 0
发帖数量: 35 个
工控威望: 85 点
下载积分: 800 分
在线时间: 35(小时)
注册时间: 2018-12-12
最后登录: 2024-10-12
查看13872434240的 主题 / 回贴
楼主  发表于: 2022-05-23 10:59
1到9这9个数,满足3位数+3位数 = 3位数 ,每个数字只能用一次,求解????
yuanbubble
级别: 略有小成
精华主题: 0
发帖数量: 151 个
工控威望: 299 点
下载积分: 247 分
在线时间: 242(小时)
注册时间: 2019-05-27
最后登录: 2024-11-15
查看yuanbubble的 主题 / 回贴
1楼  发表于: 2023-11-29 11:55
先判断加数和被加数无相等再去做加法,然后也是拆分成3位,用或运算做的,没用for循环,查到也可以填充到数组,利用数组的属性去做元素重复判断,但是没用过,就用笨一点的办法。最终数量不确定是不是包含最后一个空格,只是一个控件的行数。
                            bool b11 = (a == 0 | a == b | a == c | a == l | a == m | a == n | a == x | a == y | a == z);
                            bool b12 = (b == 0 | b == c | b == l | b == m | b == n | b == x | b == y | b == z);
                            bool b13 = (c == 0 | c == l | c == m | c == n | c == x | c == y | c == z);
                            bool b14 = (l == 0 | l == m | l == n | l == x | l == y | l == z);
                            bool b15 = (m == 0 | m == n | m == x | m == y | m == z);
                            bool b16 = (n == 0 | n == x | n == y | n == z);
                            bool b17 = (x == 0 | x == y | x == z);
                            bool b18 = (y == 0 | y == z);
                            bool b19 = (z == 0);
                            if (b11 | b12 | b13 | b14 | b15 | b16 | b17 | b18 | b19)
                            {

                            }
                            else
                            {
                                count = i.ToString() + "+" + j.ToString() + "=" + sum.ToString();
                                textBox1.AppendText(count + "\r\n");

                            }
附件: 1-9-3位数+三位数=3位数--要求不重复.rar (315 K) 下载次数:7
网站提示: 请不要用迅雷下载附件,容易出错