with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Q5K is
-- Definindo tipos para a matriz
type Matrix is array (1 .. 10, 1 .. 10) of Integer; -- Máximo de 10x10
M, Mt : Matrix; -- Matrizes M e Mt
N : Integer; -- Dimensão da matriz
begin
-- Entrada da matriz M
Put("Digite o tamanho da matriz (n x n): ");
Get(N);
Put_Line("Digite os elementos da matriz M:");
for I in 1 .. N loop
for J in 1 .. N loop
Put("Elemento (" & Integer'Image(I) & ", " & Integer'Image(J) & "): ");
Get(M(I, J));
end loop;
end loop;
-- Calculando a matriz transposta Mt
for I in 1 .. N loop
for J in 1 .. N loop
Mt(J, I) := M(I, J); -- Transpondo a matriz
end loop;
end loop;
-- Exibindo a matriz transposta Mt
Put_Line("A matriz transposta Mt é:");
for I in 1 .. N loop
for J in 1 .. N loop
Put(Integer'Image(Mt(I, J)) & " ");
end loop;
New_Line; -- Nova linha após cada linha da matriz
end loop;
end Q5K;
d2l0aCBBZGEuVGV4dF9JTzsgdXNlIEFkYS5UZXh0X0lPOwp3aXRoIEFkYS5JbnRlZ2VyX1RleHRfSU87IHVzZSBBZGEuSW50ZWdlcl9UZXh0X0lPOwoKcHJvY2VkdXJlIFE1SyBpcwogICAgLS0gRGVmaW5pbmRvIHRpcG9zIHBhcmEgYSBtYXRyaXoKICAgIHR5cGUgTWF0cml4IGlzIGFycmF5ICgxIC4uIDEwLCAxIC4uIDEwKSBvZiBJbnRlZ2VyOyAgLS0gTcOheGltbyBkZSAxMHgxMAogICAgTSwgTXQgOiBNYXRyaXg7ICAtLSBNYXRyaXplcyBNIGUgTXQKICAgIE4gOiBJbnRlZ2VyOyAgLS0gRGltZW5zw6NvIGRhIG1hdHJpegoKYmVnaW4KICAgIC0tIEVudHJhZGEgZGEgbWF0cml6IE0KICAgIFB1dCgiRGlnaXRlIG8gdGFtYW5obyBkYSBtYXRyaXogKG4geCBuKTogIik7CiAgICBHZXQoTik7CgogICAgUHV0X0xpbmUoIkRpZ2l0ZSBvcyBlbGVtZW50b3MgZGEgbWF0cml6IE06Iik7CiAgICBmb3IgSSBpbiAxIC4uIE4gbG9vcAogICAgICAgIGZvciBKIGluIDEgLi4gTiBsb29wCiAgICAgICAgICAgIFB1dCgiRWxlbWVudG8gKCIgJiBJbnRlZ2VyJ0ltYWdlKEkpICYgIiwgIiAmIEludGVnZXInSW1hZ2UoSikgJiAiKTogIik7CiAgICAgICAgICAgIEdldChNKEksIEopKTsKICAgICAgICBlbmQgbG9vcDsKICAgIGVuZCBsb29wOwoKICAgIC0tIENhbGN1bGFuZG8gYSBtYXRyaXogdHJhbnNwb3N0YSBNdAogICAgZm9yIEkgaW4gMSAuLiBOIGxvb3AKICAgICAgICBmb3IgSiBpbiAxIC4uIE4gbG9vcAogICAgICAgICAgICBNdChKLCBJKSA6PSBNKEksIEopOyAgLS0gVHJhbnNwb25kbyBhIG1hdHJpegogICAgICAgIGVuZCBsb29wOwogICAgZW5kIGxvb3A7CgogICAgLS0gRXhpYmluZG8gYSBtYXRyaXogdHJhbnNwb3N0YSBNdAogICAgUHV0X0xpbmUoIkEgbWF0cml6IHRyYW5zcG9zdGEgTXQgw6k6Iik7CiAgICBmb3IgSSBpbiAxIC4uIE4gbG9vcAogICAgICAgIGZvciBKIGluIDEgLi4gTiBsb29wCiAgICAgICAgICAgIFB1dChJbnRlZ2VyJ0ltYWdlKE10KEksIEopKSAmICIgIik7CiAgICAgICAgZW5kIGxvb3A7CiAgICAgICAgTmV3X0xpbmU7ICAtLSBOb3ZhIGxpbmhhIGFww7NzIGNhZGEgbGluaGEgZGEgbWF0cml6CiAgICBlbmQgbG9vcDsKZW5kIFE1SzsK
Digite o tamanho da matriz (n x n): Digite os elementos da matriz M:
Elemento ( 1, 1): Elemento ( 1, 2): Elemento ( 1, 3): Elemento ( 2, 1): Elemento ( 2, 2): Elemento ( 2, 3): Elemento ( 3, 1): Elemento ( 3, 2): Elemento ( 3, 3): A matriz transposta Mt é:
1 0 0
2 4 0
3 5 6