主题:MOZ进帮我解决一下(通宵等答案)
求救
[专家分:40] 发布于 2006-05-09 21:21:00
上地理课时,四个学生回答我国四大淡水湖的大小时候
甲:洞庭湖最大,洪泽湖最小,鄱阳湖第3
乙:洪泽湖最大,洞庭湖最小,鄱阳湖第2,太湖第3
丙:洪泽湖最小,洞庭湖第三
丁:鄱阳湖最大,太湖最小,洪泽湖第二,洞庭湖第三
对于每个湖水的大小,每个人只答对了一项,请判断四大湖的大小.
回复列表 (共12个回复)
沙发
求救 [专家分:40] 发布于 2006-05-09 21:23:00
想不出上面的问题帮一下谢谢
板凳
moz [专家分:37620] 发布于 2006-05-09 23:23:00
我就简单的来试试吧,希望你能看得懂.
declare sub pl (a!)
declare function y1234! (e$)
dim a$(4), b$(4), c$(4), s$(4)
a$(1) = "洞庭湖"
a$(2) = "洪泽湖"
a$(3) = "鄱阳湖"
a$(4) = "太湖"
b$(1) = "最大"
b$(2) = "第二"
b$(3) = "第三"
b$(4) = "最小"
s$(1) = "洞庭湖最大,洪泽湖最小,鄱阳湖第三"
s$(2) = "洪泽湖最大,洞庭湖最小,鄱阳湖第二,太湖第三"
s$(3) = "洪泽湖最小,洞庭湖第三"
s$(4) = "鄱阳湖最大,太湖最小,洪泽湖第二,洞庭湖第三"
for i = 1234 to 4321
pl i
k = i
y = 0
for f = 1 to 4
x = k mod 10
k = k \ 10
c$(f) = a$(f) + b$(x)
next
for g = 1 to 4
for h = 1 to 4
if instr(s$(g), c$(h)) > 0 then y = y + 1
next
y = y * 10
next
if y = 11110 then
print c$(1), c$(2), c$(3), c$(4)
exit for
end if
next
sub pl (a)
do until y1234(str$(a))
a = a + 1
loop
end sub
function y1234 (e$)
if instr(e$, "1") > 0 and instr(e$, "2") > 0 and instr(e$, "3") > 0 and instr(e$, "4") > 0 then y1234 = -1
end function
为了显得比较易懂些,
我把排列的那一块函数写得比较另类些,
希望能够看得明白
3 楼
moz [专家分:37620] 发布于 2006-05-09 23:25:00
如果中文不好支持的话,就用英文来代替试试吧.
declare sub pl (a!)
declare function y1234! (e$)
dim a$(4), b$(4), c$(4), s$(4)
a$(1) = "ddd"
a$(2) = "hhh"
a$(3) = "bbb"
a$(4) = "ttt"
b$(1) = "111"
b$(2) = "222"
b$(3) = "333"
b$(4) = "444"
s$(1) = "ddd111hhh444bbb333"
s$(2) = "hhh111ddd444bbb222ttt333"
s$(3) = "hhh444ddd333"
s$(4) = "bbb111ttt444hhh222ddd333"
for i = 1234 to 4321
pl i
k = i
y = 0
for f = 1 to 4
x = k mod 10
k = k \ 10
c$(f) = a$(f) + b$(x)
next
for g = 1 to 4
for h = 1 to 4
if instr(s$(g), c$(h)) > 0 then y = y + 1
next
y = y * 10
next
if y = 11110 then
print c$(1), c$(2), c$(3), c$(4)
exit for
end if
next
end
sub pl (a)
do until y1234(str$(a))
a = a + 1
loop
end sub
function y1234 (e$)
if instr(e$, "1") > 0 and instr(e$, "2") > 0 and instr(e$, "3") > 0 and instr(e$, "4") > 0 then y1234 = -1
end function
4 楼
求救 [专家分:40] 发布于 2006-05-09 23:33:00
一头雾哎~自己太菜了
5 楼
求救 [专家分:40] 发布于 2006-05-09 23:39:00
上面程序对新手来说太复杂看不懂
6 楼
moz [专家分:37620] 发布于 2006-05-10 00:21:00
你听说过那个故事没有? "如何向一个古代的人介绍电视机."
7 楼
moz [专家分:37620] 发布于 2006-05-10 00:28:00
declare sub pl (a!)
declare function y1234! (e$)
dim a$(4), b$(4), c$(4), s$(4)
a$(1) = "ddd" '[color=0000FF]这里是湖的名称[/color]
a$(2) = "hhh"
a$(3) = "bbb"
a$(4) = "ttt"
b$(1) = "111" '[color=0000FF]这里是排名[/color]
b$(2) = "222"
b$(3) = "333"
b$(4) = "444"
s$(1) = "ddd111hhh444bbb333" '[color=0000FF]这个是甲乙丙丁说的话[/color]
s$(2) = "hhh111ddd444bbb222ttt333"
s$(3) = "hhh444ddd333"
s$(4) = "bbb111ttt444hhh222ddd333"
for i = 1234 to 4321 '[color=0000FF]这两行实现的是1234的排列功能[/color]
pl i '[color=0000FF]用来设定四大湖的排名[/color]
k = i
y = 0
for f = 1 to 4 '[color=0000FF]分别根据当前排名来实现结果[/color]
x = k mod 10
k = k \ 10
c$(f) = a$(f) + b$(x) '[color=0000FF]某湖 排 第几[/color]
next
for g = 1 to 4 '[color=0000FF]测试四个人说的话有多少句是对的[/color]
for h = 1 to 4
if instr(s$(g), c$(h)) > 0 then y = y + 1
next
y = y * 10 '[color=0000FF]其实这一句放上三行会比较好看些[/color]
next
if y = 11110 then
print c$(1), c$(2), c$(3), c$(4) '[color=0000FF]得出结果[/color]
exit for
end if
next
end
sub pl (a) '[color=0000FF]这两个函数是用来实现排列功能的[/color]
do until y1234(str$(a))
a = a + 1
loop
end sub
function y1234 (e$) '[color=0000FF]1234缺一不可成有效的排列[/color]
if instr(e$, "1") > 0 and instr(e$, "2") > 0 and instr(e$, "3") > 0 and instr(e$, "4") > 0 then y1234 = -1
end function
8 楼
JRX [专家分:180] 发布于 2006-06-09 22:18:00
咋这么烦啊~
我的:
FOR DONG=1 TO 4
FOR HONG=1 TO 4
IF HONG<>DONG THEN
FOR B0=1 TO 4
IF (HONG<>BO) AND (BO<>DONG) THEN
TAI=10-DONG-HONG-BO
IF ((DONG=1)+(HONG=4)+(BO=3)=-1) AND ((DONG=1)+(HONG=4)+(BO=2)+(TAI=3)=-1) AND (DONG=3)+(HONG=4)=-1) AND ((BO=1)+(TAI=4)+(DONG=3)THEN
? "DONG:";DONG;"HONG:";HONG;"BO:";BO;"TAI:";TAI
ENDIF
NEXT BO
ENDIF
NEXT HONG
ENDIF
NEXT DO
END
NEXT
9 楼
LSQ [专家分:220] 发布于 2006-06-10 12:33:00
declare sub pl (a!)
declare function y1234! (e$)
dim a$(4), b$(4), c$(4), s$(4)
a$(1) = "ddd" '这里是湖的名称
a$(2) = "hhh"
a$(3) = "bbb"
a$(4) = "ttt"
b$(1) = "111" '这里是排名
b$(2) = "222"
b$(3) = "333"
b$(4) = "444"
s$(1) = "ddd111hhh444bbb333" '这个是甲乙丙丁说的话
s$(2) = "hhh111ddd444bbb222ttt333"
s$(3) = "hhh444ddd333"
s$(4) = "bbb111ttt444hhh222ddd333"
for i = 1234 to 4321 '这两行实现的是1234的排列功能
pl i '用来设定四大湖的排名
k = i
y = 0
for f = 1 to 4 '分别根据当前排名来实现结果
x = k mod 10
k = k \ 10
c$(f) = a$(f) + b$(x) '某湖 排 第几
next
for g = 1 to 4 '测试四个人说的话有多少句是对的
for h = 1 to 4
if instr(s$(g), c$(h)) > 0 then y = y + 1
next
y = y * 10 '其实这一句放上三行会比较好看些
next
if y = 11110 then
print c$(1), c$(2), c$(3), c$(4) '得出结果
exit for
end if
next
end
sub pl (a) '这两个函数是用来实现排列功能的
do until y1234(str$(a))
a = a + 1
loop
end sub
function y1234 (e$) '1234缺一不可成有效的排列
if instr(e$, "1") > 0 and instr(e$, "2") > 0 and instr(e$, "3") > 0 and instr(e$, "4") > 0 then y1234 = -1
end function
10 楼
shitbagboy [专家分:0] 发布于 2006-07-14 22:13:00
8楼的思想就是穷举四大湖的各种可能的排列,来对题设条件做判断.
我来回复