上海浦东外事服务学校:请帮忙吧,我怎么算也算不到

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/25 08:18:04
一个三位数除以一位数等于三位数.这些数必须是1到7的其中一个,而且不能重复.也就是说:
...除以.=...

624/2=312

这是一个没有答案的题目,也就是说没有这样的数字。
我花了半个小时写了下面的C程序,总算得出了上面的结果。下面是C程序的主要部分,大家看看有没有错。
#include <stdio.h>
main()
{
int x,y,z,a,b,c,m,n;
for(x=1;x<=7;x++)
for(y=1;y<=7;y++)
for(z=1;z<=7;z++)
for(n=1;n<=7;n++)
{m=(100*x+10*y+z)*n;
a=m/100;
b=(m/10)%10;
c=m%10;
if((x!=y)&&(x!=z)&&(x!=a)&&(x!=b)&&(x!=c)&&(x!=n)&&(y!=z)&&(y!=a)&&(y!=b)&&(y!=c)&&(y!=n)&&(z!=a)&&(z!=b)&&(z!=c)&&(z!=n)&&(a!=b)&&(a!=c)&&(a!=n)&&(b!=c)&&(b!=n)&&(c!=n)&&(a<8)&&(b<8)&&(c<8)&&(a!=0)&&(b!=0)&&(c!=0))
printf("%d,%d,%d,%d,%d,%d,%d,%d\n",x,y,z,m,n,a,b,c);
}
}

只要那个除数是1就行了,被除数是1到7里的随便什么数(既然不要重复,那被除数里就不要出现1就好了.)组成都没有关系.

这是一个没有答案的题目,也就是说没有这样的数字。
我花了半个小时写了下面的asp程序,总算得出了上面的结果。下面是asp程序的主要部分,大家看看有没有错。
<%
dim i
dim j

for a=1 to 7
for b=1 to 7
for c=1 to 7
for d=1 to 7
for e=1 to 7
for f=1 to 7
for g=1 to 7

if a<>b and a<>c and a<>d and a<>e and a<>f and a<>g and b<>c and b<>d and b<>e and b<>f and b<>g and c<>d and c<>e and c<>f and c<>g and d<>e and d<>f and d<>g and e<>f and e<>g and f<>g then
i=a&b&c
j=d&e&f
if i/j=g then
response.write i
response.write "/"
response.write j
response.write "="
response.write i/j
response.write "</br>"
end if
end if
next
next
next
next
next
next
next
%>

不必费脑筋了,无解

三位数除以1=三位数.