主题:[活动]50分悬赏
905482852
[专家分:380] 发布于 2009-07-07 13:18:00
【问题描述】输入M和N的值,输出M到N之间所有的绝对素数。所谓绝对素数是指一个素数,当它的倒数仍为素数,这样的素数称为绝对素数。如157本身是素数,它的倒数751也是素数,所以157就是绝对素数。
【输入文件】
文件名:JUESU.IN
文件中有两个数M和N,10≤M<N≤32767。
【输出文件】
文件名:JUESU.OUT
文件中全部为M到N之间的绝对素数。
【输入样例】
90 120
【输出样例】
97 101 107 113
回复列表 (共11个回复)
沙发
1054122 [专家分:750] 发布于 2009-07-08 10:45:00
CLS
DO
INPUT "m , n = ", m, n
IF n > m AND n < 32768 AND m > 9 THEN EXIT DO
PRINT "Input again"
LOOP
FOR i = m TO n
js = 1
FOR j = 2 TO i - 1 STEP 1
IF i MOD j = 0 THEN
js = 0
EXIT FOR
END IF
NEXT j
c$ = LTRIM$(STR$(i)): f$ = ""
FOR j = LEN(c$) TO 1 STEP -1
f$ = f$ + MID$(c$, i, 1)
NEXT j
f = VAL(f$)
FOR j = 2 TO f - 1 STEP 1
IF f MOD j = 0 THEN
bj = 0
EXIT FOR
END IF
NEXT j
IF bj = 1 THEN PRINT i;
NEXT i
END
板凳
梦幻小樱 [专家分:140] 发布于 2009-08-06 13:12:00
CLS
DO
INPUT "m , n = ", m, n
IF n > m AND n < 32768 AND m > 9 THEN EXIT DO
PRINT "Input again"
LOOP
FOR i = m TO n
js = 1
FOR j = 2 TO i - 1 STEP 1
IF i MOD j = 0 THEN
js = 0
EXIT FOR
END IF
NEXT j
c$ = LTRIM$(STR$(i)): f$ = ""
FOR j = LEN(c$) TO 1 STEP -1
f$ = f$ + MID$(c$, i, 1)
NEXT j
f = VAL(f$)
FOR j = 2 TO f - 1 STEP 1
IF f MOD j = 0 THEN
bj = 0
EXIT FOR
END IF
NEXT j
IF bj = 1 THEN PRINT i;
NEXT i
END
3 楼
phile [专家分:2310] 发布于 2009-08-06 18:43:00
你发了两次!
CLS
INPUT N,M
FOR I=N TO M
P=I
F=0
GOSUB 100
IF F=0 THEN
S$="'
DO
K=P MOD 10
S=S*10+K
P=P\10
LOOP UNTIL P=0
P=S
F=0
GOSUB 100
IF F=0 AND I>10 THEN PRINT I;
END IF
NEXT I
END
100
FOR J=2 TO SQR(P)
IF P MOD J=0 THEN F=1:RETURN
NEXT J
RETURN
4 楼
梦幻小樱 [专家分:140] 发布于 2009-08-07 13:41:00
CLS
INPUT N,M
FOR I=N TO M
P=I
F=0
GOSUB 100
IF F=0 THEN
S$="'
DO
K=P MOD 10
S=S*10+K
P=P\10
LOOP UNTIL P=0
P=S
F=0
GOSUB 100
IF F=0 AND I>10 THEN PRINT I;
END IF
NEXT I
END
100
FOR J=2 TO SQR(P)
IF P MOD J=0 THEN F=1:RETURN
NEXT J
RETURN
5 楼
phile [专家分:2310] 发布于 2009-08-07 17:48:00
梦幻小樱我警告你,你在敢抄袭!!!!
6 楼
1054122 [专家分:750] 发布于 2009-08-13 14:58:00
[quote]CLS
DO
INPUT "m , n = ", m, n
IF n > m AND n < 32768 AND m > 9 THEN EXIT DO
PRINT "Input again"
LOOP
FOR i = m TO n
js = 1
FOR j = 2 TO i - 1 STEP 1
IF i MOD j = 0 THEN
js = 0
EXIT FOR
END IF
NEXT j
c$ = LTRIM$(STR$(i)): f$ = ""
FOR j = LEN(c$) TO 1 STEP -1
f$ = f$ + MID$(c$, i, 1)
NEXT j
f = VAL(f$)
FOR j = 2 TO f - 1 STEP 1
IF f MOD j = 0 THEN
bj = 0
EXIT FOR
END IF
NEXT j
IF bj = 1 THEN PRINT i;
NEXT i
END[/quote]
严厉禁止你抄袭
我就不信你一天不抄袭就活不了
7 楼
天天和和 [专家分:1420] 发布于 2009-08-14 22:49:00
CLS
INPUT M, N
DIM Z(5)
FOR A = M TO N: I = A
FOR J = 2 TO SQR(I)
IF I MOD J = 0 THEN 10
NEXT J: K = 0
WHILE I <> 0
K = K + 1
Z(K) = I MOD 10
I = I \ 10
WEND
FOR L = 1 TO K: I = I * 10 + Z(L): NEXT L
FOR J = 2 TO SQR(I)
IF I MOD J = 0 THEN 10
NEXT J
PRINT A;
10 NEXT A
END
8 楼
FFKK [专家分:1610] 发布于 2009-08-15 17:45:00
DO
INPUT "m , n = ", m, n
IF n > m AND n < 32768 AND m > 9 THEN EXIT DO
PRINT "Input again"
LOOP
FOR i = m TO n
U = 1
FOR j = 2 TO i - 1 STEP 1
IF i MOD J = 0 THEN U= 0 EXIT FOR
NEXT j
c$ = LTRIM$(STR$(i)): f$ = ""
FOR j = LEN(c$) TO 1 STEP -1
f$ = f$ + MID$(c$, i, 1)
NEXT j
f = VAL(f$)
FOR j = 2 TO f - 1 STEP 1
IF f MOD j = 0 THEN bj = 0 EXIT FOR
NEXT j
IF bj = 1 THEN
PRINT i;
END IF
NEXT i
END
9 楼
phile [专家分:2310] 发布于 2009-08-27 09:12:00
FFKK程序不错
10 楼
905482852 [专家分:380] 发布于 2009-09-02 13:09:00
梦幻小樱你在抄袭小心我们让版主F你
我来回复