perez Posted November 17, 2009 at 06:58 PM Report Share #296691 Posted November 17, 2009 at 06:58 PM Boas, em LP o nosso stor deu-nos para TPC escrever um algoritmo em pascal que ao o user inserir o seu nome e ano de nascimento o computador devolve o nome do user e a sua idade. Este foi o algoritmo que eu escrevi: Program Idade; uses crt; var N:String[20]; I,X:Integer; Begin ClrScr; WriteLn('Digite o seu nome'); ReadLn(N); WriteLn('Digite o seu ano de nascimento'); Read(I); X := year() - I; <-| WriteLn('O teu nome é ',N,' e tens ',X,' anos'); ReadKey; End. Na linha onde tem a seta quando eu tento compilar no Turbo pascal 7.0 dá o erro "Type Missmatch". O que é isso e como posso resolver? Link to comment Share on other sites More sharing options...
M6 Posted November 17, 2009 at 09:36 PM Report Share #296722 Posted November 17, 2009 at 09:36 PM Vê o tipo de dados que a função year() devolve e coloca o X com o mesmo tipo de retorno da função. Provavelmente será um long, mas tens de ver. 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...
perez Posted November 18, 2009 at 08:03 AM Author Report Share #296742 Posted November 18, 2009 at 08:03 AM ou seja, mudo o tipo da variável X para o mesmo tipo de variável que year() devolve? Link to comment Share on other sites More sharing options...
M6 Posted November 18, 2009 at 11:33 AM Report Share #296760 Posted November 18, 2009 at 11:33 AM Sim. 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...
perez Posted November 18, 2009 at 04:57 PM Author Report Share #296778 Posted November 18, 2009 at 04:57 PM já experimentei todo o tipo de variáveis e continua a dar erro 😉 Link to comment Share on other sites More sharing options...
perez Posted November 19, 2009 at 05:40 PM Author Report Share #296913 Posted November 19, 2009 at 05:40 PM Alguém me pode ajudar? Link to comment Share on other sites More sharing options...
M6 Posted November 19, 2009 at 06:19 PM Report Share #296915 Posted November 19, 2009 at 06:19 PM Qual é o tipo de dados que a função year() devolve? 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...
perez Posted November 19, 2009 at 09:41 PM Author Report Share #296944 Posted November 19, 2009 at 09:41 PM é suposto ser números, a função year() devolve o ano Link to comment Share on other sites More sharing options...
M6 Posted November 20, 2009 at 09:53 AM Report Share #296983 Posted November 20, 2009 at 09:53 AM perez, enquanto não souberes qual o tipo de dados que a função devolve não vais conseguir resolver o 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...
perez Posted November 20, 2009 at 08:39 PM Author Report Share #297052 Posted November 20, 2009 at 08:39 PM eu já pesquisei mas não encontrei nada, o que encontrei está muito confuso, eu já tenho isso escrito o stor já não reclama, e segunda logo pergunto como é 🙂 Obrigado pela ajuda 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