antiblock
Elveron
  • Chatbox

    You don't have permission to chat.
    Load More
Sign in to follow this  
BPinto98

[Pascal] Pedido De Ajuda

16 posts in this topic

Peço desculpa desde já o Double-Post, sei que de facto deveria fazer editar invés de publicar novamente. No entanto ficaria realmente muito confuso.

 

Bem estive a analisar o meu algoritmo que publiquei no post anterior e vi que haveria de facto um erro.

Se o month<m deveria dar logo voto permitido visto já ser obrigatoriamente mais velho que o necessário. No entanto com o algoritmo anterior ainda iria sofrer mais um processo de verificação que seria o dos dias que podia tornar impedido o voto quando deveria de facto autorizar. Pelo que o algoritmo iria ter o que lhe chama-mos de BUG. Por isso estive a alterar o código e aqui fica as alterções eheh :)

 

RachadoPT depois vê se está bom e comenta, o que devo alterar ainda para aperfeiçoar... Lembro que sou novato nisto ehehe xP

program pascaleleicoes;
uses DOS;

var age,day,month,year:integer;
var y,m,d,wd:word;

begin
	GetDate(y, m, d, wd);
        writeln('Introduza o seu Dia de Nascimento (Numero)');
        readln(day);
        writeln('Introduza o seu Mes de Nascimento (Numero)');
        readln(month);
        writeln('Introduza o seu Ano de Nascimento (Numero)');
	readln(year);
	age := y - year;

	if age > 18 then
		writeln('Ja pode votar!');
        if age = 18 then
                Begin
                if month<m then
                        writeln('Ja pode votar!');
                if month=m then
                        Begin
                        if day<d then
                        writeln('Ja pode votar!');
                        if day=d then
                        writeln('Ja pode votar!');
                        if day>d then
                        writeln('Nao pode votar...');
                        end;
                if month>m then
                writeln('Nao pode votar...')
                end;
        if age < 18 then
		writeln('Nao pode votar...');
        readln();
end.   

Share this post


Link to post
Share on other sites
antiblock
diamwall

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this