anficori Posted October 29, 2009 at 10:56 PM Report Share #293956 Posted October 29, 2009 at 10:56 PM Boas Pessoal, estou com um problematizo e precisava da vossa ajuda, Dado um número com três algarismos calcula o mínimo múltiplo comum entre esses três algarismos. Dim a As Integer Dim b As Integer Dim c As Integer Dim um As Integer Dim dois As Integer Dim tres As Integer If (TextBox1.Text > 100 And TextBox1.Text < 999) Then tres = TextBox1.Text Mod 10 dois = (TextBox1.Text / 10) Mod 10 um = ((TextBox1.Text / 10) / 10) Mod 10 For i = 0 To 9 a = um * i For k = 0 To 9 b = dois * k If (a = b) Then For j = 0 To 9 c = tres * j If (a = c And b = c) Then Label1.Text = a End If Next End If Next Next End If Mas só calcula algumas vezes não dá sempre. e Se for inserido o numero 236, o resultado devia ser 6 e dá-me 12:S alguém me pode ajudar ? Obrigado Link to comment Share on other sites More sharing options...
Gooden Posted October 30, 2009 at 10:32 AM Report Share #293987 Posted October 30, 2009 at 10:32 AM (TextBox1.Text / 10) Mod 10 se o numero na textbox for 236 vai dar 4..... Pensa bem porque.... faz antes assim: tres = TextBox1.Text.Substring(2) dois = TextBox1.Text.Substring(1, 1) um = TextBox1.Text.Substring(0, 1) fazendo isto já da 6. Link to comment Share on other sites More sharing options...
anficori Posted October 30, 2009 at 02:56 PM Author Report Share #294040 Posted October 30, 2009 at 02:56 PM mas o meu principal é objectivo é utilizar este bloco em pseudo-código, só passei para vb para confirmar. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now