with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Q5H is
N : Integer; -- Número de elementos
A : array (1 .. 100) of Integer; -- Array para armazenar os elementos
begin
-- Leitura do número de elementos
Put_Line("Digite o número de elementos (até 100):");
Get(N);
-- Leitura dos elementos do array
Put_Line("Digite os elementos:");
for I in 1 .. N loop
Get(A(I));
end loop;
-- Algoritmo Bubble Sort para ordenar o array
for I in 1 .. N - 1 loop
for J in 1 .. N - I loop
if A(J) > A(J + 1) then
-- Troca A(J) e A(J + 1)
declare
Temp : Integer := A(J);
begin
A(J) := A(J + 1);
A(J + 1) := Temp;
end;
end if;
end loop;
end loop;
-- Exibe os elementos ordenados
Put_Line("Elementos em ordem crescente:");
for I in 1 .. N loop
Put(Integer'Image(A(I))); -- Converte o inteiro para string para exibir
Put(" "); -- Adiciona um espaço
end loop;
New_Line;
end Q5H;
d2l0aCBBZGEuVGV4dF9JTzsgdXNlIEFkYS5UZXh0X0lPOwp3aXRoIEFkYS5JbnRlZ2VyX1RleHRfSU87IHVzZSBBZGEuSW50ZWdlcl9UZXh0X0lPOwoKcHJvY2VkdXJlIFE1SCBpcwogICBOIDogSW50ZWdlcjsgIC0tIE7Dum1lcm8gZGUgZWxlbWVudG9zCiAgIEEgOiBhcnJheSAoMSAuLiAxMDApIG9mIEludGVnZXI7ICAtLSBBcnJheSBwYXJhIGFybWF6ZW5hciBvcyBlbGVtZW50b3MKCmJlZ2luCiAgIC0tIExlaXR1cmEgZG8gbsO6bWVybyBkZSBlbGVtZW50b3MKICAgUHV0X0xpbmUoIkRpZ2l0ZSBvIG7Dum1lcm8gZGUgZWxlbWVudG9zIChhdMOpIDEwMCk6Iik7CiAgIEdldChOKTsKCiAgIC0tIExlaXR1cmEgZG9zIGVsZW1lbnRvcyBkbyBhcnJheQogICBQdXRfTGluZSgiRGlnaXRlIG9zIGVsZW1lbnRvczoiKTsKICAgZm9yIEkgaW4gMSAuLiBOIGxvb3AKICAg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