Function ds(ByVal n As Integer) As Integer 'Сумма цифр в числе n Dim s As Integer s = 0 Do While n <> 0 s = s + n Mod 10 n = Int(n / 10) Loop ds = s End Function
Function IsGood(n As Integer) As Boolean 'Сохраняется ли сумма цифр при умножении числа на 2,3,..9 ? Dim etalon As Integer, k As Integer etalon = ds(n) IsGood = True k = 2 Do While IsGood And k < 10 IsGood = (ds(n * k) = etalon) k = k + 1 Loop End Function
Sub aaa() Dim i As Integer, s As String s = "" For i = 10 To 99 If IsGood(i) Then s = s + Str(i) Next i MsgBox s End Sub
Program z1; Var a: array [1..100,1..100] of integer; i,j,n,m,min,t:integer;Begin write('Введите кол-во столбцов - '); readln(n); write('Введите кол-во строк - '); readln(m); randomize; for j:=1 to m do begin for i:=1 to n do begin a[i][j]:=random(9)-0; write (a[i][j],' '); end; writeln; end; min:=a[1][4]; t:=1; for i:=2 to n do begin if (a[i][4]<min) then begin min:=a[i][4]; t:=i; end; end; writeln('Минимальный элемент - ',min); writeln('Столбец - ',t);End.
'Сумма цифр в числе n
Dim s As Integer
s = 0
Do While n <> 0
s = s + n Mod 10
n = Int(n / 10)
Loop
ds = s
End Function
Function IsGood(n As Integer) As Boolean
'Сохраняется ли сумма цифр при умножении числа на 2,3,..9 ?
Dim etalon As Integer, k As Integer
etalon = ds(n)
IsGood = True
k = 2
Do While IsGood And k < 10
IsGood = (ds(n * k) = etalon)
k = k + 1
Loop
End Function
Sub aaa()
Dim i As Integer, s As String
s = ""
For i = 10 To 99
If IsGood(i) Then s = s + Str(i)
Next i
MsgBox s
End Sub
Тестовое решение:
18 45 90 99