106) Для узла с IP-адресом 212.168.104.5 адрес сети равен 212.168.104.0. Найдите наименьшее возможное количество нулей в двоичной записи маски подсети.
begin Randomize; for i := 1 to n do for j := 1 to n do X[i,j] := Random(100); for i := 1 to n do begin IndMax := 1; max :=X[i,1]; for j := 2 to n do begin if X[i,j]>max then begin max := X[i,j]; //Наибольший элемент строки с номером i IndMax := j; //Столбец, в котором находится наибольший элемент строки //с номером i end; end; //Смена элементов X[i,IndMax] := X[i,i]; X[i,i] := max; end; end;
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
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