Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
ordenar.adb
--3 5 4 9 --> 3 4 5 9 with Ada.Integer_text_io; use Ada.Integer_text_io; procedure ordenar is --Entrada: 4 enteros --salida: 4 enteros d1, d2, d3, d4 --Post: di son los de la entrada y d1<d2<d3<d4 d1, d2, d3, d4 : Integer; Aux : Integer; begin get(d1); get(d2); get(d3); get(d4); if d1>d2 and d1>d3 and d1>d4 then aux := d4; d4:=d1; d1:= Aux; elsif d2>d1 and d2>d3 and d2>d4 then aux := d4; d4:=d2; d2:= Aux; elsif d3>d1 and d3>d2 and d3 > d4 then aux := d4; d4:=d3; d3:= Aux; else --d4 >d1 and d4>d2 and d4>d3 null; end if; if d1>d2 and d1>d3 then aux := d3; d3:=d1; d1:= Aux; elsif d2>d1 and d2>d3 then aux := d3; d3:=d2; d2:= Aux; else --d3 >d1 and d3>d2 null; end if; if d1>d2 then aux := d2; d2:=d1; d1:= Aux; else --d3 >d1 and d3>d2 null; end if; put(d1); put(d2); put(d3); put(d4); end ordenar; --- CASOS DE PRUEBA: 1 2 3 4 + 4
run
|
edit
|
history
|
help
0
ada rocks!
1d array as 4d with easy reshaping
Ada nested lexical scope
Ada.adb
Memory Alignment
Queue (Using Tasking)
Dynamic Dispatching with dynamic allocation
Normal Random Numbers
Dynamic Dispatching with no dynamic allocation
Stack (Using Tasking)