Function Bin(s As String, z As Integer) As String Dim c As Integer Dim oct As Integer c = Val(s) Do oc = c Mod 2 c = c \ 2 Bin = Bin & Str(oc) Loop Until c = 0 Bin = StrReverse(Bin) If z = -1 Then Bin = "-" & Bin End Function
Sub z() Dim s As String, s1 As String Dim n As Integer, i As Integer, z As Integer Dim max s = InputBox("Введите строку: ") max = Null i = 1 Do While i <= Len(s) Select Case Mid(s, i, 1) Case 0 To 9 If z = 0 And i > 1 Then z = IIf(Mid(s, i - 1, 1) = "-", -1, 1) Else: z = 1 End If s1 = s1 + Mid(s, i, 1) If i = Len(s) Then GoSub 1 Case Else: If s1 <> "" Then GoSub 1 End Select i = i + 1 Loop MsgBox ("max=" & max) End 1: n = z * Val(s1) MsgBox (n & "; двоичная форма: " & Bin(s1, z)) If IsNull(max) Then max = n If max < n Then max = n z = 0 s1 = "" Return End Sub
1) 1000010 1101001 1101110 1100001 1110010 1111001 100000 1100011 1101111 1100100 1101001 1101110 1100111 - (66 105 110 97 114 121 32 99 111 100 105 110 103)
2) 1001001 1101110 1100110 1101111 1110010 1101101 1100001 1110100 1101001 1100011 1100001 - (73 110 102 111 114 109 97 116 105 99 97)
3) 1001011 1100001 1111010 1100001 1101011 1101000 1110011 1110100 1100001 1101110 - (75 97 122 97 107 104 115 116 97 110)
4) 1010010 1111001 1101011 1101000 1100001 1101110 1101001 100000 1101010 1100001 1101110 1100111 1111001 1110010 1110101 - (82 121 107 104 97 110 105 32 106 97 110 103 121 114 117)
Function Bin(s As String, z As Integer) As String
Dim c As Integer
Dim oct As Integer
c = Val(s)
Do
oc = c Mod 2
c = c \ 2
Bin = Bin & Str(oc)
Loop Until c = 0
Bin = StrReverse(Bin)
If z = -1 Then Bin = "-" & Bin
End Function
Sub z()
Dim s As String, s1 As String
Dim n As Integer, i As Integer, z As Integer
Dim max
s = InputBox("Введите строку: ")
max = Null
i = 1
Do While i <= Len(s)
Select Case Mid(s, i, 1)
Case 0 To 9
If z = 0 And i > 1 Then
z = IIf(Mid(s, i - 1, 1) = "-", -1, 1)
Else: z = 1
End If
s1 = s1 + Mid(s, i, 1)
If i = Len(s) Then GoSub 1
Case Else:
If s1 <> "" Then GoSub 1
End Select
i = i + 1
Loop
MsgBox ("max=" & max)
End
1: n = z * Val(s1)
MsgBox (n & "; двоичная форма: " & Bin(s1, z))
If IsNull(max) Then max = n
If max < n Then max = n
z = 0
s1 = ""
Return
End Sub