Bài tập Mảng 1
Thu Jun 20, 2024 9:10 pm
Viết ct pascal Lập matrix 100 số ngẫu nhiên từ 1..10. Tính tổng đường chéo chính [
GIẢI
GIẢI
- Code:
uses crt;
var t,x,i,j:integer;
a:array[1..10,1..10] of integer;
begin
clrscr;
randomize;
t:=0;
for i:=1 to 10 do
for j:=1 to 10 do
begin
x:=random(10)+1;
a[i,j]:=x;
end;
writeln('MA TRAN');
for i:=1 to 10 do
begin
t:=t+a[i,i];
for j:=1 to 10 do
write(a[i,j]:5);
writeln;
end;
writeln;
writeln('Tong cac chu so tren duong cheo chinh la ',t:3);
readln
end.
Permissions in this forum:
Bạn không có quyền trả lời bài viết
|
|