d10g0l1r1 Posted June 9, 2008 at 09:59 AM Report Share #190231 Posted June 9, 2008 at 09:59 AM Este programa deve ler o valor inicial de um título numa bolsa de volores e depois fazer de forma aleatória 30 vezes um amuento ou diminuição de 0.01. É necessário usar funções e procedimentos. Bem, estou a precisar de ajuda. Se alguém me pudesse corrigir o seguinte código ficaria muito agradecido: program bolsa (input,output); var r:integer; valorinicial:integer; valorbolsa:real; c:integer; function naleatorio:integer; begin randomize; r:=random(100)+1; naleatorio:=r; end; function repet(r:integer):real; begin if (r>0) and (r<51) then repet:=0.01 else if (r>51) and (r<101) then repet:=-0.01; end; procedure final; begin for c:=1 to 30 do begin valorbolsa:=valorinicial+repet(naleatorio); writeln (valorbolsa:0:2); end; end; begin naleatorio; writeln ('Qual o valor inicial?'); readln (valorinicial); final; writeln (valorbolsa:0:2); readln; end. Muito obrigado!!! Hasta 😞 Link to comment Share on other sites More sharing options...
M6 Posted June 9, 2008 at 04:43 PM Report Share #190285 Posted June 9, 2008 at 04:43 PM Para te ajudar, tens de dizer qual é o teu problema. 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to comment Share on other sites More sharing options...
d10g0l1r1 Posted June 10, 2008 at 12:28 PM Author Report Share #190447 Posted June 10, 2008 at 12:28 PM Epa o problema éque eu não consigo fazer aleatoriamente (30 vezes) osimulação do aumento ou diminuiçãodo tíyulo (em 0.01). Se copiarem o programa para pascal verão o problema. Link to comment Share on other sites More sharing options...
M6 Posted June 11, 2008 at 09:10 PM Report Share #190769 Posted June 11, 2008 at 09:10 PM Epa o problema éque eu não consigo fazer aleatoriamente (30 vezes) osimulação do aumento ou diminuiçãodo tíyulo (em 0.01). Se copiarem o programa para pascal verão o problema. Não tenho Pascal instalado para testar, mas posso tentar ajudar. Uma das primeiras coisas que vejo que devem ser eliminadas são as variáveis globais, isso é só corda para um tipo se enforcar, além de não permitir certos tipos de optimização por parte dos compiladores. Depois, o teu problema é que não faz as 30 vezes ou não faz a oscilação? 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." 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