with Ada.Text_IO ; use Ada.Text_IO ;
with Ada.Integer_Text_IO ; use Ada.Integer_Text_IO ;
procedure Q5M is
-- Definindo o tipo para a matriz
type Matrix is array ( 1 .. 10 , 1 .. 10 ) of Integer; -- Máximo de 10x10
A : Matrix; -- Matriz A
N : Integer; -- Dimensão da matriz
Diagonal_Sum : Integer := 0 ; -- Soma da diagonal principal
begin
-- Entrada da matriz A
Put( "Digite o tamanho da matriz (n): " ) ;
Get( N) ;
Put_Line( "Digite os elementos da matriz A:" ) ;
for I in 1 .. N loop
for J in 1 .. N loop
Put( "Elemento (" & Integer'Image( I) & ", " & Integer'Image( J) & "): " ) ;
Get( A( I, J) ) ;
end loop ;
end loop ;
-- Calculando a soma dos elementos da diagonal principal
for I in 1 .. N loop
Diagonal_Sum := Diagonal_Sum + A( I, I) ;
end loop ;
-- Exibindo a soma da diagonal principal
Put_Line( "A soma dos elementos da diagonal principal é: " & Integer'Image( Diagonal_Sum) ) ;
end Q5M;
d2l0aCBBZGEuVGV4dF9JTzsgdXNlIEFkYS5UZXh0X0lPOwp3aXRoIEFkYS5JbnRlZ2VyX1RleHRfSU87IHVzZSBBZGEuSW50ZWdlcl9UZXh0X0lPOwoKcHJvY2VkdXJlIFE1TSBpcwogICAgLS0gRGVmaW5pbmRvIG8gdGlwbyBwYXJhIGEgbWF0cml6CiAgICB0eXBlIE1hdHJpeCBpcyBhcnJheSAoMSAuLiAxMCwgMSAuLiAxMCkgb2YgSW50ZWdlcjsgIC0tIE3DoXhpbW8gZGUgMTB4MTAKICAgIEEgOiBNYXRyaXg7ICAtLSBNYXRyaXogQQogICAgTiA6IEludGVnZXI7ICAtLSBEaW1lbnPDo28gZGEgbWF0cml6CiAgICBEaWFnb25hbF9TdW0gOiBJbnRlZ2VyIDo9IDA7ICAtLSBTb21hIGRhIGRpYWdvbmFsIHByaW5jaXBhbAoKYmVnaW4KICAgIC0tIEVudHJhZGEgZGEgbWF0cml6IEEKICAgIFB1dCgiRGlnaXRlIG8gdGF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