Algoritmo+de+foça+bruta+em+VBA++(Problema+das+embalagens,+panos+e+papeis)

code format="vb" Sub algoritmo_forca_bruta

Dim maximo As Integer Dim valorx As Integer Dim valory As Integer Dim total As Integer

maximo = 0 valorx = 0 valory = 0

For x = 0 To 1000

For y = 0 To 2000

If ((x + y <= 800) And (x + y <= 1000) And (x + 5 * y <= 2000)) Then 'Restriçoes do problema total = x + 1.75 * y 'função lucro

If (total > maximo) Then

maximo = total valorx = x               valory = y

End If

End If

Next y Next x

Range("A1").Cells = "Programação Linear" Range("A2").Cells = "Lucro Máximo" Range("A3").Cells = maximo Range("B2").Cells = "Valor de x" Range("B3").Cells = valorx Range("C2").Cells = "Valor de y" Range("C3").Cells = valory End Sub code