13872434240
級別: 正式會員
|
1到9這9個數(shù),滿足3位數(shù)+3位數(shù) = 3位數(shù) ,每個數(shù)字只能用一次,求解???? |
---|---|
|
選擇性智障
級別: 略有小成
|
先判斷加數(shù)和被加數(shù)無相等再去做加法,然后也是拆分成3位,用或運算做的,沒用for循環(huán),查到也可以填充到數(shù)組,利用數(shù)組的屬性去做元素重復(fù)判斷,但是沒用過,就用笨一點的辦法。最終數(shù)量不確定是不是包含最后一個空格,只是一個控件的行數(shù)。 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"); } |
---|---|
|