主题:来者加分!!!
随便你好
[专家分:530] 发布于 2007-08-14 10:16:00
在一次竞赛中,甲、乙、丙、丁四人分获前四名,在公布名次前,他们进行猜测:
甲说: 乙会获得第一名;
乙说: 丁会获得第二名;
丙说: 甲会获得第二名;
丁说: 丙会获得第三名;
其中,只有获得第一名和第三名的两人猜对了。编程判断甲、乙、丙、丁各获得第几名?
回复列表 (共5个回复)
沙发
QB小猪 [专家分:1200] 发布于 2007-08-14 10:18:00
CLS
FOR i = 1 TO 4
READ x$(i)
NEXT i
DATA Jia,Yi,Bing,Ding
FOR a = 1 TO 4: a(1) = a
FOR b = 1 TO 4: a(2) = b
FOR c = 1 TO 4: a(3) = c
d = 10 - a - b - c: a(4) = d
IF a * b * c * d <> 24 THEN 10
IF (b = 1) + (d = 2) + (a = 2) + (c = 3) <> -2 THEN 10
n = 0
IF (a = 1 OR a = 3) AND b = 1 THEN n = n + 1
IF (b = 1 OR b = 3) AND d = 2 THEN n = n + 1
IF (c = 1 OR c = 3) AND a = 2 THEN n = n + 1
IF (d = 1 OR d = 3) AND c = 3 THEN n = n + 1
IF n <> 2 THEN 10
FOR i = 1 TO 4
PRINT x$(i); ":"; a(i),
NEXT i: PRINT
10 NEXT c, b, a
END
[em1][em2][em3][em4][em5][em6][em7][em8][em9][em10][em11][em12][em13][em14][em15][em16][em17][em18][em19][em20][em50][em66][em54][em53][em43][em1][em74]
板凳
爱丽斯LING [专家分:560] 发布于 2007-08-14 10:22:00
CLS
FOR i = 1 TO 4
READ x$(i)
NEXT i
DATA Jia,Yi,Bing,Ding
FOR a = 1 TO 4: a(1) = a
FOR b = 1 TO 4: a(2) = b
FOR c = 1 TO 4: a(3) = c
d = 10 - a - b - c: a(4) = d
IF a * b * c * d <> 24 THEN 10
IF (b = 1) + (d = 2) + (a = 2) + (c = 3) <> -2 THEN 10
n = 0
IF (a = 1 OR a = 3) AND b = 1 THEN n = n + 1
IF (b = 1 OR b = 3) AND d = 2 THEN n = n + 1
IF (c = 1 OR c = 3) AND a = 2 THEN n = n + 1
IF (d = 1 OR d = 3) AND c = 3 THEN n = n + 1
IF n <> 2 THEN 10
FOR i = 1 TO 4
PRINT x$(i); ":"; a(i),
NEXT i: PRINT
10 NEXT c, b, a
END
3 楼
网虫一号 [专家分:1230] 发布于 2007-08-14 10:23:00
CLS
FOR i = 1 TO 4:READ x$(i):NEXT i
DATA Jia,Yi,Bing,Ding
FOR a = 1 TO 4: a(1) = a
FOR b = 1 TO 4: a(2) = b
FOR c = 1 TO 4: a(3) = c
d = 10 - a - b - c: a(4) = d
IF a * b * c * d <> 24 THEN 10
IF (b = 1) + (d = 2) + (a = 2) + (c = 3) <> -2 THEN 10
n = 0
IF (a = 1 OR a = 3) AND b = 1 THEN n = n + 1
IF (b = 1 OR b = 3) AND d = 2 THEN n = n + 1
IF (c = 1 OR c = 3) AND a = 2 THEN n = n + 1
IF (d = 1 OR d = 3) AND c = 3 THEN n = n + 1
IF n <> 2 THEN 10
FOR i = 1 TO 4:PRINT x$(i); ":"; a(i),:NEXT i: PRINT
10 NEXT c, b, a
END
4 楼
我的电脑 [专家分:990] 发布于 2007-08-14 10:24:00
CLS
FOR i = 1 TO 4
READ x$(i)
NEXT i
DATA Jia,Yi,Bing,Ding
FOR a = 1 TO 4: a(1) = a
FOR b = 1 TO 4: a(2) = b
FOR c = 1 TO 4: a(3) = c
d = 10 - a - b - c: a(4) = d
IF a * b * c * d <> 24 THEN 10
IF (b = 1) + (d = 2) + (a = 2) + (c = 3) <> -2 THEN 10
n = 0
IF (a = 1 OR a = 3) AND b = 1 THEN n = n + 1
IF (b = 1 OR b = 3) AND d = 2 THEN n = n + 1
IF (c = 1 OR c = 3) AND a = 2 THEN n = n + 1
IF (d = 1 OR d = 3) AND c = 3 THEN n = n + 1
IF n <> 2 THEN 10
FOR i = 1 TO 4
PRINT x$(i); ":"; a(i),
NEXT i: PRINT
10 NEXT c, b, a
END
5 楼
小精灵1号 [专家分:1040] 发布于 2007-08-14 10:27:00
CLS
FOR i = 1 TO 4
READ x$(i)
NEXT i
DATA Jia,Yi,Bing,Ding
FOR a = 1 TO 4: a(1) = a
FOR b = 1 TO 4: a(2) = b
FOR c = 1 TO 4: a(3) = c
d = 10 - a - b - c: a(4) = d
IF a * b * c * d <> 24 THEN 10
IF (b = 1) + (d = 2) + (a = 2) + (c = 3) <> -2 THEN 10
n = 0
IF (a = 1 OR a = 3) AND b = 1 THEN n = n + 1
IF (b = 1 OR b = 3) AND d = 2 THEN n = n + 1
IF (c = 1 OR c = 3) AND a = 2 THEN n = n + 1
IF (d = 1 OR d = 3) AND c = 3 THEN n = n + 1
IF n <> 2 THEN 10
FOR i = 1 TO 4
PRINT x$(i); ":"; a(i),
NEXT i: PRINT
10 NEXT c, b, a
END
我来回复