0
The code below should sort the numbers typed in ascending order, but when typed 5,3 and 8 respectively, the program displays them out of order.
program {
funcao inicio()
{
//variaveis
inteiro i
real a, b, c
real menor=0.0, meio=0.0, maior=0.0
leia(i)
leia(a)
leia(b)
leia(c)
se(i==1){
se(a>b e b>c)
maior = a
meio = b
menor = c
}
senao se(a>c e c>b){
maior = a
meio = c
menor = b
}
senao se(b>a e a>c){
maior = b
meio = a
menor = c
}
senao se(b>c e c>a){
maior = b
meio = c
menor = a
}
senao se(c>a e a>b){
maior = c
meio = a
menor = b
}
senao se(c>b e b>a){
maior = c
meio = b
menor = a
}
escreva("\nmenor = ", menor)
escreva("\nmeio = ", meio)
escreva("\nmaior = ", maior)
}
}
pq there is the variable
i
and when we should enter these i==1
?– Luiz Augusto
The problem proposed by the teacher has several conditions, such as i==2, i==3, but my difficulty is only in the ascending order.
– João Rosa