Program lab5; const n=5; Var P: array [1..n,1..n] of real; i, j : integer; Begin Randomize; writeln('Исходный массив P:'); for i:=1 to n do begin for j:=1 to n do begin P[i,j]:=10*random; write(P[i,j]:5:1); end; writeln; end; for i:=1 to n do for j:=1 to n do if j>i then P[i,j]:=0 else P[i,j]:=round(P[i,j]); writeln('Изменённый массив P:'); for i:=1 to n do begin for j:=1 to n do write(P[i,j]:5:1); writeln; end; End.
const n=5;
Var
P: array [1..n,1..n] of real;
i, j : integer;
Begin
Randomize;
writeln('Исходный массив P:');
for i:=1 to n do
begin
for j:=1 to n do
begin
P[i,j]:=10*random;
write(P[i,j]:5:1);
end;
writeln;
end;
for i:=1 to n do
for j:=1 to n do
if j>i then P[i,j]:=0 else P[i,j]:=round(P[i,j]);
writeln('Изменённый массив P:');
for i:=1 to n do
begin
for j:=1 to n do write(P[i,j]:5:1);
writeln;
end;
End.
Пример:
Исходный массив P:
6.0 6.5 4.2 0.6 4.6
5.7 8.8 0.3 6.2 9.0
3.0 5.3 4.0 6.0 4.8
6.0 3.0 5.0 5.3 8.7
8.9 8.8 6.8 5.3 5.1
Изменённый массив P:
6.0 0.0 0.0 0.0 0.0
6.0 9.0 0.0 0.0 0.0
3.0 5.0 4.0 0.0 0.0
6.0 3.0 5.0 5.0 0.0
9.0 9.0 7.0 5.0 5.0
uses System;
uses System.Collections;
begin
var d := DateTime.Today;
repeat
d := d.AddDays(1);
until d.DayOfWeek = DayOfWeek.Sunday;
var Sundays := new Dictionary<integer, integer>();
repeat
if Sundays.ContainsKey(d.Year) then
Sundays[d.Year] += 1
else
Sundays.Add(d.Year, 1);
d := d.AddDays((-7));
until d.Year <= 1;
var max := Sundays.Values.Max;
Sundays.Where(x -> x.Value = max).Println;
end.