with Ada.Text_IO ; use Ada.Text_IO ;
with Ada.Integer_Text_IO ; use Ada.Integer_Text_IO ;
procedure Q5B is
M, N : Integer;
A, B, C : array ( 1 .. 100 ) of Integer; -- Tamanho máximo dos vetores
I : Integer;
begin
-- Leitura do tamanho dos vetores
Put_Line( "Digite o tamanho do vetor A (m):" ) ;
Get( M) ;
Put_Line( "Digite o tamanho do vetor B (n):" ) ;
Get( N) ;
-- Verifica se os tamanhos são compatíveis
if M /= N then
Put_Line( "Os vetores devem ter o mesmo tamanho." ) ;
return ;
end if ;
-- Leitura do vetor A
Put_Line( "Digite os elementos do vetor A:" ) ;
for I in 1 .. M loop
Get( A( I) ) ;
end loop ;
-- Leitura do vetor B
Put_Line( "Digite os elementos do vetor B:" ) ;
for I in 1 .. N loop
Get( B( I) ) ;
end loop ;
-- Soma dos vetores A e B, armazenando em C
for I in 1 .. M loop
C( I) := A( I) + B( I) ;
end loop ;
-- Exibição do vetor C
Put_Line( "Vetor C (soma de A e B):" ) ;
for I in 1 .. M loop
Put( C( I) , 1 ) ;
if I < M then
Put( " " ) ; -- Coloca um espaço entre os elementos
end if ;
end loop ;
New_Line;
end Q5B;
d2l0aCBBZGEuVGV4dF9JTzsgdXNlIEFkYS5UZXh0X0lPOwp3aXRoIEFkYS5JbnRlZ2VyX1RleHRfSU87IHVzZSBBZGEuSW50ZWdlcl9UZXh0X0lPOwoKcHJvY2VkdXJlIFE1QiBpcwogICBNLCBOIDogSW50ZWdlcjsKICAgQSwgQiwgQyA6IGFycmF5ICgxIC4uIDEwMCkgb2YgSW50ZWdlcjsgLS0gVGFtYW5obyBtw6F4aW1vIGRvcyB2ZXRvcmVzCiAgIEkgOiBJbnRlZ2VyOwoKYmVnaW4KICAgLS0gTGVpdHVyYSBkbyB0YW1hbmhvIGRvcyB2ZXRvcmVzCiAgIFB1dF9MaW5lKCJEaWdpdGUgbyB0YW1hbmhvIGRvIHZldG9yIEEgKG0pOiIpOwogICBHZXQoTSk7CiAgIFB1dF9MaW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