9+1=8改成三道算式每次只能改0到9组成一个加法算式符号,和数字

3914人阅读
C# 基础(18)
此题咱没想出很巧妙的解法,直接根据编程来吧
using System.Collections.G
using System.T
namespace RemainerMaths
class Program
static void Main(string[] args)
int count = 0;//可能性个数
int[] a ={ 1, 2, 3, 4, 5, 6, 7, 8, 9 };
for (int i = 0; i & a.L i++)
for (int j = 0; j & a.L j++)
for (int k = 0; k & a.L k++)
if (a[i] != a[j] && a[j] != a[k] && a[k] != a[i])
//从9个数中随机找出3个数组成三位数
int add1 = 100 * a[i] + 10 * a[j] + a[k];
//将剩下的6个数字组成一个数组
int[] b = GetNewArray(a, i, j, k);
for (int x = 0; x & b.L x++)
for (int y = 0; y & b.L y++)
for (int z = 0; z & b.L z++)
if (b[x] != b[y] && b[y] != b[z] && b[z] != b[x])
//从这6个数中随机找出3个数组成三位数
int add2 = 100 * b[x] + 10 * b[y] + b[z];
//将剩下的3个数字组成一个数组
int[] c = GetNewArray(b, x, y, z);
//获得最后剩下的3个数字组成的所有三位数
int[] lastNumber = GetAllThreeNumber(c);
//如果两数之和等于第三个数就输出
for (int index = 0; index & lastNumber.L index++)
if (add1 + add2 == lastNumber[index])
Console.WriteLine(&{0} + {1} = {2}&, add1, add2, lastNumber[index]);
Console.WriteLine(&共有[{0}]种情形-因加法存在交换律,则实际有[{1}]种情形。&, count, count/2);
Console.ReadLine();
/// &summary&
/// 由原数组,去除掉索引在i、j、k处的元素后形成的新数组
/// &/summary&
/// &param name=&a&&&/param&
/// &param name=&i&&&/param&
/// &param name=&j&&&/param&
/// &param name=&k&&&/param&
/// &returns&&/returns&
static int[] GetNewArray(int[] a, int i, int j, int k)
List&int& list = new List&int&();
for (int temp = 0; temp & a.L temp++)
if (temp != i && temp != j && temp != k)
list.Add(a[temp]);
int[] b = list.ToArray();
/// &summary&
/// 获得由最后三个数字组成的所有三位数
/// &/summary&
/// &param name=&list&&&/param&
/// &returns&&/returns&
static int[] GetAllThreeNumber(int[] list)
List&int& temp = new List&int&();
if (list == null || list.Length != 3)
return temp.ToArray();
temp.Add(100 * list[0] + 10 * list[1] + list[2]);
temp.Add(100 * list[0] + 10 * list[2] + list[1]);
temp.Add(100 * list[1] + 10 * list[0] + list[2]);
temp.Add(100 * list[1] + 10 * list[2] + list[0]);
temp.Add(100 * list[2] + 10 * list[0] + list[1]);
temp.Add(100 * list[2] + 10 * list[1] + list[0]);
return temp.ToArray();
输出结果:
。。。。。。
&&相关文章推荐
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:91146次
积分:1629
积分:1629
排名:千里之外
原创:76篇
评论:20条
(6)(5)(10)(6)(3)(20)(1)(18)(16)账号 电子邮箱地址
记住登录状态
还没有33IQ账号?
通过社交网站直接登录
条@我的评论,
条新私信,
条新评论,
09:57 提供
1+2+3+4+5+6+7+8+9=45如何改一个符号使等式的结果为100?
您也可能感兴趣的题目
登录33IQ,提升智力水平,让你越玩越聪明!
33IQ v4.26.90.82
Copyright & 2008- All Rights Reserved扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
下载作业帮安装包
扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
把1一9九个数字填在括号里,每个数字只能用1次,组成三道正确算式()+()=() ()-()=()把1一9九个数字填在括号里,每个数字只能用1次,组成三道正确算式()+()=()()-()=()()x()=()
窝窝小夜kd
扫二维码下载作业帮
拍照搜题,秒出答案,一键查看所有搜题记录
2x3=61+7=89-4=5
为您推荐:
其他类似问题
扫描下载二维码

我要回帖

更多关于 6个3相加写成乘法算式 的文章

 

随机推荐