1.
with open("name.txt") as f:
massiv=f.read().split("\n")
length = len(massiv)
for i in range(length):
for j in range(0, length-i-1):
if massiv[j] > massiv[j+1]:
massiv[j],massiv[j+1]=massiv[j+1],massiv[j]
with open("name1.txt", "w") as f:
for i in massiv:
f.write(i + "\n")
2.
with open("input.txt") as f:
massiv=map(int,f.read().split("\n"))
with open("output.txt","w") as f:
f.write(str(max(massiv)))
3.
days=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturnday", "Sunday"]
if 1<int(i)<7:
f.write(days[i-1]+"\n")
else:
f.write("There is no such day of the week.\n")
##
var a := MatrRandom(10, 10, 0, 50);
a.print(4);
var s,i:integer;
s:=0;
for i:= 0 to 9 do
if a[i, 9-i] mod 3 = 0 then
inc(s, a[i, 9-i]);
print('Сумма=',s);
-------------free pascal-------------
var
a:array[0..9, 0..9]of integer;
i, j, s : integer;
begin
randomize;
for i:=0 to 9 do begin
for j:= 0 to 9 do begin
a[i,j]:= random(50);
write(a[i,j],' ')
end;
writeln();
for i:=0 to 9 do
if a[i,9-i] mod 3 = 0 then
s:=s+a[i,9-i];
writeln(s)
end.
1.
with open("name.txt") as f:
massiv=f.read().split("\n")
length = len(massiv)
for i in range(length):
for j in range(0, length-i-1):
if massiv[j] > massiv[j+1]:
massiv[j],massiv[j+1]=massiv[j+1],massiv[j]
with open("name1.txt", "w") as f:
for i in massiv:
f.write(i + "\n")
2.
with open("input.txt") as f:
massiv=map(int,f.read().split("\n"))
with open("output.txt","w") as f:
f.write(str(max(massiv)))
3.
days=["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturnday", "Sunday"]
with open("input.txt") as f:
massiv=map(int,f.read().split("\n"))
with open("output.txt","w") as f:
for i in massiv:
if 1<int(i)<7:
f.write(days[i-1]+"\n")
else:
f.write("There is no such day of the week.\n")
##
var a := MatrRandom(10, 10, 0, 50);
a.print(4);
var s,i:integer;
s:=0;
for i:= 0 to 9 do
if a[i, 9-i] mod 3 = 0 then
inc(s, a[i, 9-i]);
print('Сумма=',s);
-------------free pascal-------------
var
a:array[0..9, 0..9]of integer;
i, j, s : integer;
begin
randomize;
for i:=0 to 9 do begin
for j:= 0 to 9 do begin
a[i,j]:= random(50);
write(a[i,j],' ')
end;
writeln();
end;
s:=0;
for i:=0 to 9 do
if a[i,9-i] mod 3 = 0 then
s:=s+a[i,9-i];
writeln(s)
end.