Jump to content

until....


Guest tsenart

Recommended Posts

Posted

Olá pessoal... Estou a escrever este código que funciona bem sem o ciclo repeat mas com ele(com o while) diz-me que não posso usar operadores logicos com caracteres.... Entao como é que eu faço aquele while?

program vinte_pontoseis;

var
maior,menor,temp:real;
quant,cont:integer;
ans:char;

begin
    writeln;

write('        AMPLITUDE TeRMICA');
writeln;
writeln;
repeat
repeat

          writeln('Quantos valores vai introduzir?'); readln(quant);

        until quant>=2;


        write('Introduza um valor:  '); readln(temp);
maior:=temp;

for cont:=2 to quant do
	begin
	write('Introduza outro valor:  '); readln(temp);
	if temp>maior then
	   begin
	   menor:=maior;
	   maior:=temp;
	   end
	else
		menor:=temp;
	end;
writeln('A amplitude tErmica E: ',maior-menor:2:1,'graus');
        writeln;
        writeln('Quer repetir?'); readln(ans);
        
until ans='n' OR ans='N';

end.

Posted

Experimenta, em vez de

readln(ans);
until ans='n' OR ans='N';

fazer

ans=readkey;
until ord(ans)=ord('n') OR ord(ans)=ord('N');

Desaparecido.

Posted

Não podes fazer isto assim

readln(ans);
until ans='n' OR ans='N';

Tens de por parentesis assim

readln(ans);
until (ans='n') OR (ans='N');

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
×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.