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
// PascalABC.NET 3.1, сборка 1174 от 22.02.2016
begin
Writeln(Range(1,100).Select(i->sin(i)*cos(i)).Where(x->x<>0).Average)
end.
Тестовое решение:
-0.00136006072493969
2. А вот так учат писать это же школьные учителя:
// PascalABC.NET 3.1, сборка 1174 от 22.02.2016
var
m:array[1..100] of real;
i,k:integer;
s:real;
begin
s:=0;
k:=0;
for i:=1 to 100 do begin
m[i]:=sin(i)*cos(i);
if m[i]<>0 then begin
s:=s+m[i];
k:=k+1
end
end;
Writeln(s/k)
end.
Тестовое решение:
-0.00136006072493969
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