Page 48 - MATINF Nr. 7
P. 48
48 N. St˘aniloiu
CalcSbm2=NrSbm
End Function
Public Function CalcSbm3(k As Integer) As Integer
Dim Max As Long
Dim Cont As Long
N=k
Max=1
For i=1 To N
Max=Max * 2
Next i
NrSbm=Max
For Cont=1 To Max
Dim Cond1, Cond2, Cond3 As Boolean
Bin Cont-1
For i=1 To N
Cond1=(B(i-1)=0) And (B(i)=1) And (B(i+1)=0)
Cond2=(B(i-1)=0) And (B(i)=1) And (B(i+1)=1) And (B(i+2)=0)
Cond3=(B(i-1)=0) And (B(i)=1) And (B(i+1)=1) And (B(i+2)=1) And (B(i+3)=0)
If Cond1 Or Cond2 Or Cond3 Then
NrSbm=NrSbm-1
Exit For
End If
Next i
Next Cont
CalcSbm3=NrSbm
End Function
Public Sub Bin(x As Integer)
For i=1 To N
B(i)=x Mod 2
x=Int(x / 2)
Next i
B(0)=0
B(N+1)=0
B(N+2)=0
B(N+3)=0
End Sub