domingo, 6 de fevereiro de 2011

Ordem crescente de 3 números

program ordem_crescente;
uses crt;
 procedure crescente (var a, b, c: integer);
 begin
   if (a<b) and (a<c) and (b<c) then writeln ('Ordem crescente:',a,',',b,',',c)
   else
    if (a<b) and (a<c) and (c<b) then writeln ('Ordem crescente:',a,',',c,',',b)
    else
     if (b<a) and (b<c) and (a<c) then writeln ('Ordem crescente:',b,',',a,',',c)
     else
      if (b<a) and (b<c) and (c<a) then writeln ('Ordem crescente:',b,',',c,',',a)
      else
       if (c<a) and (c<b) and (a<b) then writeln ('Ordem crescente:',c,',',a,',',b)
       else
        if (c<a) and (c<b) and (b<a) then writeln ('Ordem crescente:',c,',',b,',',a)
   end;
   var x, y, z: integer;
   begin
     clrscr;
     writeln ('Digite os numeros');
     readln (x, y, z);
     writeln ('Os numeros digitados sao:', x,',', y,',', z);
     crescente(x,y,z);
     readkey;
   end.

Nenhum comentário:

Postar um comentário