Faça um programa Pascal que leia do teclado números inteiros maiores ou iguais a zero do teclado, até que um número negativo seja digitado. Escreva os três maiores valores digitados. Caso apenas dois número não negativo seja digitado, informe esse fato.
Preciso mostrar o "maio"r,"segundo maior" e o "terceiro maior",de certa forma o programa até faz isso...,porém se passar de 4 elementos ele,pega o ultimo valor e compara com o penultimo e daí o terceiro maior fica sendo a comparação do ultimo com o penultimo valor digitado...,droga só agora percebi que o ideal seria ter usado um vetor,mas nao tenho mas cabeça pra pensar em fazer um na altura do campeonato,mas como programação sempre tem um jeito,to pedindo ajuda para que nao tenha que ganhar metade dos pontos da questão.
program ex3;
uses
crt;
var
cont,n,aux,maior, segundomaior,terceiromaior:integer;
Fim : boolean;
BEGIN
TextColor(15);
ClrScr;
Fim:=false;
aux:=0;
cont:=0;
maior:=0;
segundomaior:=0;
terceiromaior:=0;
writeln(' Digite valores, para terminar a execuçao insira um numero negativo.');
while not Fim do
begin
write('Digite um valor: ');
readln(n);
if n<0 then
Fim:=true
else
begin
cont:= cont + 1;
if n >= maior then
begin
maior := n
end
else
begin
if n >= segundomaior then
segundomaior:= n
else
if (n<maior) then
terceiromaior:=n;
end;
end;
end;
if cont = 2 then
writeln ('Apenas Dois numero foi digitado.')
else
begin
writeln('O maior valor é : ', maior );
writeln('O segundo maior valor é: ', segundomaior);
writeln('O terceiro maior é : ', terceiromaior);
end;
{read(maior);}
ReadKey; {aguarda uma tecla ser precionada}
end.
Pergunta:
Faça um programa Pascal que leia do teclado números inteiros maiores ou iguais a zero do teclado, até que um número negativo seja digitado. Escreva os dois menores valores e os dois maiores valores. Caso apenas um número não negativo seja digitado, informe esse fato.
Segue resposta abaixo:
var
n, menornumero, menornumero2, maiornumero, maiornumero2, pronto, cont : integer;
begin
menornumero := 999;
menornumero2 := 999;
maiornumero := 0;
maiornumero2 := 0;
pronto := 1;
while ( pronto = 1) do begin
writeln ('digite um numero');
readln(n);
if (n < 0) then begin
pronto := 0;
end;
cont := cont +1;
if (n < menornumero) and (n <> -1) then begin
menornumero := n;
end;
if (n > menornumero) and (n < menornumero2) then begin
menornumero2 := n;
end;
if (n > maiornumero) then begin
maiornumero := n;
end;
if (maiornumero > n) and (n > maiornumero2) then begin
maiornumero2 := n;
end;
end;
if (cont = 1) then begin
writeln ('você digitou apenas 1 numero ou apenas 1 maior que -1');
end else begin
writeln ('Dois menores numeros são',menornumero,' e ',menornumero2);
writeln ('Dois maiores numeros são',maiornumero,' e ',maiornumero2);
end;
end.
Thanks for the useful information,stay safe. Zebra Quinceanera Dress | Wine and Gold Quinceanera Dress | Turtleneck Quinceanera Dress | Sheer Top Quinceanera Dress | Scoop Neck Quinceanera Dress |
Bem, este é um programa muito simples. É improvável que isso possa ser útil para qualquer empresa. Se você está procurando algo realmente bom, recomendamos que você acesse o site com o programa software de monitoramento de funcionários. Este é um programa que permite acompanhar as ações de seus funcionários. Isso é algo incrível e completamente novo. Você já tentou isso?
Xo สล็อตออนไลน์ โปรสล็อต XO เกมออนไลน์ทำเงินยอดฮิตเกมสล็อต xopg.net คือเกมทำเงิน reeffutures2018 ผ่านทางออนไลน์อย่างหนึ่ง ที่เล่นง่าย และได้เงินไว แถมยังลงทุนด้วยเงินน้อย mavoixtavoie ทำเงินได้ตลอดเวลา ซึ่งหลายคนอาจได้เคยเห็นรีวิวเรื่องของ สล็อต xo สล็อตออนไลน์ ไว้มากมาย เทคนิคสล็อต ทั้งเรื่องการเล่นแล้วได้เงิน herbalpertpresents และเล่น สล็อต แล้วไม่ได้เงิน นั่นเองค่ะ ซึ่งการที่คุณจะเล่นได้เงินหรือไม่ได้เงินนั้น essentialsforasoul ส่วนหนึ่งก็เป็นในเรื่องของดวงเข้ามาเกี่ยวด้วย northbristol เพราะสล็อตเป็นเกมออนไลน์เสี่ยงโชค ทดลองเล่น xo เกมหนึ่งซึ่งจะมีสูตร หรือเทคนิคเข้ามาช่วย gclub เพื่อโกงดวงอยู่เสมอซึ่งในเว็บของเรา สมัคร xo ก็มีมาแนะนำไว้ให้เห็นกันมากมายหลายสูตร
I'd break down the phrases and find the spots that I could jump in and join in the song and sing along. I'd listen to the music and try to find places to inject my own energy and personality into the song. https://kiil.no/2022/01/27/11114/
Hmm… I interpret blogs on a analogous issue, however i never visited your blog. I added it to populars also i’ll be your faithful primer. 사설토토
Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... 안전놀이터
You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. 벳삼
I invite you to the page where see how much we have in common. 토토커뮤니티
You possess lifted an essential offspring..Blesss for using..I would want to study better latest transactions from this blog..preserve posting.. 꽁머니사이트
I read this article. I think You put a lot of effort to create this article. I appreciate your work. 링크찾기
The most interesting text on this interesting topic that can be found on the net ... 링크찾기
I use only high quality materials - you can see them at: 링크사이트
Well done! I appreciate your blog post to this matter. It has been insightful. my blog: master cleanse 먹튀검증
In order to be healthy, you need to do prevention https://vacuumbuttlift.com/
I like material like this. This is a great article and I really enjoyed reading it. You have an original style that makes your ideas stand out from other writers. 먹튀인증
You need to be a part of a contest for one of the most useful blogs on the internet. I am going to recommend this web site! 토토커뮤니티
I like this site its a master peace ! Glad I detected this on google . 꽁머니
I discovered your website internet site on the internet and appearance some of your early posts. Always keep up the very good operate. I simply additional increase your RSS feed to my MSN News Reader. Seeking forward to reading a lot more on your part down the line!… 홈런 토토