Module Module1 Sub Main() Dim input(1) As Integer For i As Integer = 0 To 1 input(i) = Val(Console.ReadLine()) Next Dim result = Enumerable.Range(1, input.Max() - 1). Where(Function(n) Dim r As Boolean = True input.ToList().ForEach(Function(m) If m Mod n <> 0 Then r = False End Function) Return r End Function).Select(Function(n) n).Max() Console.WriteLine(result) End SubEnd Module 24 32 8
Module Module1 Sub Main() Dim input(1) As Integer For i As Integer = 0 To 1 input(i) = Val(Console.ReadLine()) Next Dim result = Enumerable.Range(1, input.Max() - 1). Where(Function(n) Dim r As Boolean = True input.ToList().ForEach(Function(m) If m Mod n <> 0 Then r = False End Function) Return r End Function).Select(Function(n) n).Max() Console.WriteLine(result) End SubEnd Module
Module Module1 Sub Main() Dim input(1) As Integer For i As Integer = 0 To 1 input(i) = Val(Console.ReadLine()) Next Dim result = Enumerable.Range(1, input.Max()). Where(Function(n) Dim r As Boolean = True input.ToList().ForEach(Function(m) If m Mod n <> 0 Then r = False End Function) Return r End Function).Select(Function(n) n).Max() Console.WriteLine(result) End SubEnd Module
Public Function 最大公约数(a As Integer, b As Integer) As Integer Dim t As Integer If a < b Then t = a: a = b: b = t
While b <> 0 t = a Mod b: a = b: b = t Wend
最大公约数 = a End Function
一贴一回。 已经回答完了,lz你贴到VB 2010运行成功就给分吧。
VB.NET 不行,俺用VB6中文专业版
他写错了,应该是 Super Man
Public Function 最大公约数(a As Integer, b As Integer) As Integer Dim t As Integer If a < b Then t = a: a = b: b = t
Dim input(1) As Integer
For i As Integer = 0 To 1
input(i) = Val(Console.ReadLine())
Next
Dim result = Enumerable.Range(1, input.Max() - 1).
Where(Function(n)
Dim r As Boolean = True
input.ToList().ForEach(Function(m)
If m Mod n <> 0 Then r = False
End Function)
Return r
End Function).Select(Function(n) n).Max()
Console.WriteLine(result)
End SubEnd Module
24
32
8
Dim input(1) As Integer
For i As Integer = 0 To 1
input(i) = Val(Console.ReadLine())
Next
Dim result = Enumerable.Range(1, input.Max() - 1).
Where(Function(n)
Dim r As Boolean = True
input.ToList().ForEach(Function(m)
If m Mod n <> 0 Then r = False
End Function)
Return r
End Function).Select(Function(n) n).Max()
Console.WriteLine(result)
End SubEnd Module
Dim input(1) As Integer
For i As Integer = 0 To 1
input(i) = Val(Console.ReadLine())
Next
Dim result = Enumerable.Range(1, input.Max()).
Where(Function(n)
Dim r As Boolean = True
input.ToList().ForEach(Function(m)
If m Mod n <> 0 Then r = False
End Function)
Return r
End Function).Select(Function(n) n).Max()
Console.WriteLine(result)
End SubEnd Module
Public Function 最大公约数(a As Integer, b As Integer) As Integer
Dim t As Integer
If a < b Then t = a: a = b: b = t
While b <> 0
t = a Mod b: a = b: b = t
Wend
最大公约数 = a
End Function
已经回答完了,lz你贴到VB 2010运行成功就给分吧。
他写错了,应该是 Super Man
Dim t As Integer
If a < b Then t = a: a = b: b = t
While b <> 0
t = a Mod b: a = b: b = t
Wend
最大公约数 = a
End Function