- which version of turbo c have you used?
- have you used the structured or unstructured version?
- what about the compiler directives like range checking for Basic or C?
One problem is that some results are very close to each other. So I try to have 2 or better 3 significant digits for measurement. If the execution is too fast for some Basic versions, please add a FOR NEXT loop to have more accurate timing. Sorry for the trouble.
Code : Tout sélectionner
10 CLEAR:DEFINT A-Z
20 R=8
30 REM DIM A(R) (DIM used if necessary)
33 FOR N=1 TO 10
36 S=0:X=0
40 IF X=R THEN 180
50 X=X+1
60 A(X)=R
70 S=S+1
80 Y=X
90 Y=Y-1
100 IF Y=0 THEN 40
110 T=A(X)-A(Y)
120 IF T=0 THEN 140
130 IF X-Y<>ABS T THEN 90
140 A(X)=A(X)-1
150 IF A(X)<>0 THEN 70 (<>0 omitted if possible)
160 X=X-1
170 IF X<>0 THEN 140 (<>0 omitted if possible)
180 NEXT
190 PRINT S




