Var f,s:text; st,sp:string; i:integer; c:char; begin assign(s,'text1.txt'); reset(s); while not Eof(s) do begin; readln(s,sp); st:=st+sp+chr(10)+chr(13); end; close(s); for i:=1 to length(st) div 2 do begin c:=st[i]; st[i]:=st[length(st)-i+1]; st[length(st)-i+1]:=c; end; assign(f,'text.txt'); rewrite(f); write(f,st); close(f); end.
Текст в файле text1.txt:
Simple text 1And another simple text 2New text
Текст в файле text.txt: txet weN2 txet elpmis rehtona dnA1 txet elpmiS
1)
a = [12,32,51,2,5,-10,-20,23,-23] # задаете любой массив
a.sort()
minim = 0
maxim = 0
for i in range(len(a)):
if a[i] % 2 == 0:
minim = a[i]
break
a = list(reversed(a))
for i in range(len(a)):
if a[i] % 2 == 0:
maxim = a[i]
break
print(minim)
print(maxim)
2)
a = [12,32,51,2,1,-10,-20,21,-23]
a.sort()
minim = 0
maxim = 0
for i in range(len(a)):
if a[i] % 10 == 5:
minim = a[i]
break
a = list(reversed(a))
for i in range(len(a)):
if a[i] % 10 == 5:
maxim = a[i]
break
if minim == 0 and maxim == 0:
print('No')
else:
print(minim)
print(maxim)
Var
f,s:text;
st,sp:string;
i:integer;
c:char;
begin
assign(s,'text1.txt');
reset(s);
while not Eof(s) do
begin;
readln(s,sp);
st:=st+sp+chr(10)+chr(13);
end;
close(s);
for i:=1 to length(st) div 2 do
begin
c:=st[i];
st[i]:=st[length(st)-i+1];
st[length(st)-i+1]:=c;
end;
assign(f,'text.txt');
rewrite(f);
write(f,st);
close(f);
end.
Текст в файле text1.txt:
Simple text
1And another simple text
2New text
Текст в файле text.txt:
txet weN2
txet elpmis rehtona dnA1
txet elpmiS