欢迎您访问52IJ教育培训网,今天小编为你分享的数学方面的学习知识是通过网络精心收集整理的:“魔法学徒好看吗_...以为分这么好得么?yayoyoya - 魔法学徒 一级好厉...[数学]”,注意:所整理内容不代表本站观点,如你有补充或疑问请在正文下方的评论处发表。下面是详细内容。
一种比较笨的方法,不知道有没有漏掉的:
设三个数分别为:abc、uvw、xyz,由uvw=2abc可以得到:2c->w为偶数.
所有可能的w、z、c组合为:
w=2 2 4 4 6 6 8 8
c=1 6 2 7 3 8 4 9
z=3 8 6 1 9 4 2 7
a只能为1、2、3,所有a、u、x的可能组合为(abc+uvw=xyz->a+u=x或a+u+1=x,uvw=2abc->2a=u或2a+1=u):
a=1 1 1 1 2 2 2 2 3
u=2 2 3 3 4 4 5 5 6
x=3 4 4 5 6 7 7 8 9
所有可能没有重复数字的
a_c u_w x_y 剩余的数字
1_8 2_6 3_4 5、7、9
1_9 2_8 3_7 4、5、6
1_3 2_6 4_9 5、7、8
1_9 2_8 4_7 3、5、6
1_6 3_2 4_8 5、7、9
1_9 3_8 4_7 2、5、6
1_6 3_2 5_8 4、7、9
1_2 3_4 5_6 7、8、9
1_8 3_6 5_4 2、7、9
1_4 3_8 5_2 6、7、9
1_9 3_8 5_7 2、4、6
2_9 4_8 6_7 1、3、5
2_3 4_6 7_9 1、5、8
2_3 5_6 7_9 1、4、8
2_8 5_6 7_4 1、3、9
2_7 5_4 8_1 3、6、9
2_3 5_6 8_9 1、4、7
3_7 6_4 9_1 2、5、8
3_4 6_8 9_2 1、5、7
结果:
192 384 576
219 438 657
273 546 819
327 654 981
其他回答
333\666\999
其他类似问题
问题1:将1-9共9个数字分成三组,分别组成3个三位数,使这三个三位数构成1:2:3[数学科目]
192 384 576
问题2:用C#语言将1,2,3...9九位数分成三组,组成3个三位数且满足1:2:3的比例,
之前回答过同样的问题.
这个就是给这道题写的
using System;using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List
int x = 0, y = 0, z = 0;
for (int i = 1; i < 10; i++) _L1.Add(i);
foreach (int a in _L1)
{
List
_L2.Remove(a);
foreach (int b in _L2)
{
List
_L3.Remove(b);
foreach (int c in _L3)
{
x = a * 100 + b * 10 + c;
List
_L4.Remove(c);
foreach (int d in _L4)
{
List
_L5.Remove(d);
foreach (int e in _L5)
{
List
_L6.Remove(e);
foreach (int f in _L6)
{
y = d * 100 + e * 10 + f;
List
_L7.Remove(f);
foreach (int g in _L7)
{
List
_L8.Remove(g);
foreach(int h in _L8)
{
List
_L9.Remove(h);
z = g * 100 + h * 10 + _L9[0];
if (y == x * 2 && z == x * 3)
Console.WriteLine(x + "," + y + "," + z);
}
}
}
}
}
}
}
}
Console.ReadKey();
}
}
}
下面这个用到了强制代码,你自己取舍,两个都可以实现,第一个基本逻辑思路,第二个简化算法,节省时间
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
List
for (int i = 1; i < 10; i++) _L1.Add(i);
foreach (int x in _L1)
{
List
_L2.Remove(x);
foreach (int y in _L2)
{
List
_L3.Remove(y);
foreach (int z in _L3)
{
int i = x * 100 + y * 10 + z;
int ii = i * 2;
char[] cii = ii.ToString().ToCharArray();
if (cii[0] == cii[1] || cii[0] == cii[2] || cii[1] == cii[2]) continue;
List
_L4.Remove(z);
foreach (char c in cii)
{
if (!_L4.Contains(int.Parse(c.ToString())))goto H1;
}
int iii = i * 3;
char[] ciii=iii.ToString().ToCharArray();
if (ciii[0] == ciii[1] || ciii[0] == cii[2] || ciii[1] == ciii[2]) continue;
List
foreach (char c in cii) _L5.Remove(int.Parse(c.ToString()));
foreach (char c in ciii)
{
if (!_L5.Contains(int.Parse(c.ToString())))
goto H1;
}
Console.WriteLine(i + "," + ii + "," + iii);
H1: ;
}
}
}
Console.ReadKey();
}
}
}
问题3:pascal 巧妙填数 将1,2,…,9共9个数分成三组,分别组成三个三位数,且使这三个三位数构成 1:2:3的比例试求出所有满足条件的三个三位数. 例如:三个三位数192,384,576满足以上条件.无输入输出:
程序:
program l_1(input,output);
var
a:array[0..9] of integer;
f:boolean;
i,ii,iii,j:integer;
procedure fl(x:integer);
begin
while x0 do
begin
a[x mod 10]:=a[x mod 10]+1;
x:=x div 10;
end;
end;
begin
for i:=123 to 321 do
begin
fillchar(a,sizeof(a),0)
ii:=i*2;
iii:=i*3;
fl(i);
fl(ii);
fl(iii);
f:=true;
for j:=0 to 9 do
if a[j]=0 then f:=false;
if f=true then writeln(i:5,ii:5,iii:5);
end;
end.
输出结果你自己走一遍就行了,我这没装环境,抱歉~
问题4:编写程序,将1到9这九个数字分成三个三位数,要求:第2个三位数是第1个三位数的两倍;第3个三位数是第1个#include int a[9];int OK(int t,int *s){int *p,*q;for(p=s; p
先回答后面一个
根据定义int a[9];来看,a是指针,指向整型数组a的第1个元素
a+3和a+6也都是指针,分别指向整型数组a的第4个元素和第7个元素
前面那个问题回答起来要麻烦些,因为你要理解了算法的思路才知道代码是想做什么.
首先这个算法是要枚举,范围设置在123~333想必不难理解吧.
现在我举其中一些例子来说明算法思路.
当第一个数等于123时,根据题意,后两个数分别为246和369
先把123拆成数字1,2,3写到数组a的前三个元素中,并且验证写进去的数字都不等于0而且互不相等(这就是你问的*p==0,以及*q==*p的意思)
如果出现0,不在1~9之间自然不行,出现了重复的数字也不符合题意,所以只要出现这两种情况中的任何一种,就要return 0,表示这个数字不行.
当然,1,2,3既没有0也没有重复,所以接下来将246的每一位写到a数组接下来的三个元素中,现在a数组变成了1 2 3 2 4 6
当对第四个元素2进行*q==*p判断时发现与第二个元素相等,所以123肯定不能是第一个数.于是循环到m=124,再重复上面的过程.
如果发现一直到第九个数字都既没有出现0也没有重复,那么满足题意,输出,同时计数.
当然,程序中也有不严谨的地方.比如OK函数检验到出现0和出现重复时返回了0,但是当外层for循环结束时应该有return(1);这样的语句,不然main函数中的if语句永远也判断不出true,所以还需要改进.
问题5:把1.2.3.4.5.6.7.8.9九个自然数分成3个三位数,( )( )( )=( )( )( )/2=( )( )( )/3[数学科目]
经计算,共有4组满足要求的数:
192 = 384/2 = 576/3
219 = 438/2 = 657/3
273 = 546/2 = 819/3
327 = 654/2 = 981/3
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
