A,B,C,D,E,F是1到9之间得到任何数,ABCDEF*2=CDEFAB,CDEFAB*2=EFABCD,ABCDEF这六位数是什么
1个回答
展开全部
a = 1, b = 4, c = 2, d = 8, e = 5, f = 7
C代码:
# include <stdio.h>
//根据题意确定循环上下限
int max = 1000000;
int min = 1000000 / 2 / 2;
int ABCDEF;
int CDEFAB;
int EFABCD;
int main(int argc, char **argv)
{
for (ABCDEF = 100000; ABCDEF < min; ABCDEF++)
{
int A = ABCDEF / 100000;
int B = (ABCDEF % 100000) / 10000;
int C = (ABCDEF % 10000) / 1000;
int D = (ABCDEF % 1000) / 100;
int E = (ABCDEF % 100) / 10;
int F = (ABCDEF % 10);
if (C <= A || E <= C)
{
continue;
}
CDEFAB = C * 100000 + D * 10000 +
E * 1000 + F * 100 + A * 10 + B;
if (CDEFAB != ABCDEF * 2)
{
continue;
}
EFABCD = E * 100000 + F * 10000 + A * 1000 +
B * 100 + C * 10 + D;
if (EFABCD == CDEFAB * 2)
{
printf("找到:%d\n", ABCDEF);
}
}
return 0;
}
C代码:
# include <stdio.h>
//根据题意确定循环上下限
int max = 1000000;
int min = 1000000 / 2 / 2;
int ABCDEF;
int CDEFAB;
int EFABCD;
int main(int argc, char **argv)
{
for (ABCDEF = 100000; ABCDEF < min; ABCDEF++)
{
int A = ABCDEF / 100000;
int B = (ABCDEF % 100000) / 10000;
int C = (ABCDEF % 10000) / 1000;
int D = (ABCDEF % 1000) / 100;
int E = (ABCDEF % 100) / 10;
int F = (ABCDEF % 10);
if (C <= A || E <= C)
{
continue;
}
CDEFAB = C * 100000 + D * 10000 +
E * 1000 + F * 100 + A * 10 + B;
if (CDEFAB != ABCDEF * 2)
{
continue;
}
EFABCD = E * 100000 + F * 10000 + A * 1000 +
B * 100 + C * 10 + D;
if (EFABCD == CDEFAB * 2)
{
printf("找到:%d\n", ABCDEF);
}
}
return 0;
}
追问
啊!牛大哥,厉害
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询