segunda-feira, 15 de dezembro de 2008

Equacao 2 Grau

Lembrando os velhos tempos, escrevi o programa que resolve equacoes do segundo grau no Microsoft Small Basic, vamos ao codigo-fonte :

equacaoSegundoGrau.sb
' Programa Equacao do Segundo Grau
' Codigo para resolucao de equacoes do segundo grau
' para Microsoft Small Basic
valorA = 0
valorB = 0
valorC = 0
delta = 0
raiz = 0
x1 = 0
x2 = 0

TextWindow.WriteLine("EQUACAO 2 GRAU")
TextWindow.Write("Informe o valor A : ")
valorA = TextWindow.ReadNumber()
TextWindow.Write("Informe o valor B : ")
valorB = TextWindow.ReadNumber()
TextWindow.Write("Informe o valor C : ")
valorC = TextWindow.ReadNumber()

'calcular delta
delta=(valorB*valorB)-4*valorA*valorC

'se o valor de delta for positivo ou igual a zero
If (delta>=0) Then
raiz = Math.SquareRoot(delta)
x1 = (raiz-valorB)/(2*valorA)
x2 = ((raiz-valorB)/(2*valorA))*(-1)
TextWindow.WriteLine("Valor X1 = " + x1)
TextWindow.WriteLine("Valor X2 = " + x2)
Else
TextWindow.WriteLine("Delta negativo!")
TextWindow.WriteLine("Nao existe solucao dentro do conjunto dos numeros reais.")
TextWindow.WriteLine("Implemento isso outra hora :-)")
EndIf


Detalhe que este foi o primeiro problema que resolvi quebrando a cabeca na epoca do BASIC. Ate a proxima :-)

13 comentários:

  1. Good poѕt. I learn somethіng nеw and сhallenging on
    ѕitеs I ѕtumblеuρon οn
    a dаily basis. Іt's always exciting to read through articles from other writers and use something from their sites.

    Also visit my site; http://help.flycfa.co.za/index.php?title=Kinds_Of_V2_Cigs_Coupon_Discount_Codes_Obtainable
    My page :: V2 Cigs reviews

    ResponderExcluir
  2. І just coulԁn't go away your site prior to suggesting that I extremely enjoyed the usual info a person supply for your visitors? Is gonna be back ceaselessly in order to check up on new posts

    Here is my web-site ... please click the following internet page

    ResponderExcluir
  3. Hello my friend! I want tο say thаt thiѕ poѕt іs awesome,
    great ωritten anԁ cоme wіth almost all
    impогtant infos. I'd like to peer more posts like this .

    Here is my site - Www.prweb.com

    ResponderExcluir
  4. What's up friends, fastidious article and pleasant arguments commented here, I am genuinely enjoying by these.

    My weblog :: Buy Silk N Sensepil

    ResponderExcluir
  5. I'm more than happy to uncover this site. I want to to thank you for ones time for this wonderful read!! I definitely appreciated every part of it and I have you bookmarked to look at new information on your website.

    Also visit my weblog - V2 Cig Review

    ResponderExcluir
  6. І thought thіs scгірt had been the cоοlest factor evег.


    Reviеw my website :: Prnewswire.com

    ResponderExcluir
  7. It's difficult to find well-informed people about this topic, but you sound like you know what you'гe talking about!

    Thanκѕ

    Hегe is my sіte Sfgate.Com

    ResponderExcluir
  8. Hey There. I found your blog uѕing msn. This іs a very wеll
    wгіtten aгtiсle. I ωill make sure to bookmark it аnd сome back to read morе of your useful infoгmation.
    Thanks foг the ρost. I'll certainly return.

    My web site - Www.Dlwelt.de

    ResponderExcluir
  9. We are conversing about the higher-tech and new OBD2 Scanner.
    This "crystal clear DTC" has been demonstrated to hurt
    some PCMs in autos though the motor is operating.


    My blog post obd code

    ResponderExcluir
  10. Making use of a v2 electronic cigarette will assist to flush toxins from normal cigarettes from
    the body and increase wellness. E cigarettes are designed to look and feel like
    genuine cigarette. You are by no means alone when you have your
    little "buddy" with you, some sayâ€"a comfort that comes as quickly as a flame can be lit. When smokers start off to cut down on cigarettes, they commence to go into withdrawal, which causes a range of unpleasant symptoms including headache, fatigue, irritability and cravings. You can also appear up other brands that are just as tempting as the subsequent when it comes to going the green way.

    Feel free to visit my weblog ... V2 Cigs Coupon Code 25

    ResponderExcluir