
Нафанаил
7 год назад
Нельзя преобразовать тип integer к char. Как это исправить?
Var
F, L, R, S : char;
a, b : integer;
begin
a : = 0;
b : = 0;
F : = 1;
L : = 0;
R : = 0;
S : = 0;
Assign(input,'input.txt');
Reset(input);
Assign(output,'output.txt');
Rewrite(output);
Read(F,L,R,S);
if F then
begin
a : = a+F
end;
if L then
begin
b : = b+L
end;
if R then
begin
b : = b-R
end;
if S then
begin
a : = a+S;
b : = b+S
end;
write(a,b);
End.
ОТВЕТЫ

Losusin
Aug 12, 2019
//Не смотрел Ваш код, просто моё видение решения задачи
//PascalABC.NET 3.2 сборка 1318
Var
t:text;
x,y,i,j:integer;
s:string;
c:char;
world:array[1..4] of char=(E,S,W,N);
begin
j:=1;
c:=E;
assign(t,input.txt);
reset(t);
read(t,s);
close(t);
i:=1;
while s[i]lt;gt;S do
begin
if s[i]=R then
begin
if c=N then j:=1 else inc(j);
c:=world[j];
end;
if s[i]=L then
begin
if c=E then j:=4 else dec(j);
c:=world[j];
end;
if s[i]=F then
case c of
E:inc(x);
S:dec(y);
W:dec(x);
N:inc(y);
end;
inc(i);
end;
assign(t,output.txt);
rewrite(t);
write(t,x, ,y);
close(t);
end.
Пример содержимого input.txt:
FLFS
Пример содержимого output.txt:
1 1
//PascalABC.NET 3.2 сборка 1318
Var
t:text;
x,y,i,j:integer;
s:string;
c:char;
world:array[1..4] of char=(E,S,W,N);
begin
j:=1;
c:=E;
assign(t,input.txt);
reset(t);
read(t,s);
close(t);
i:=1;
while s[i]lt;gt;S do
begin
if s[i]=R then
begin
if c=N then j:=1 else inc(j);
c:=world[j];
end;
if s[i]=L then
begin
if c=E then j:=4 else dec(j);
c:=world[j];
end;
if s[i]=F then
case c of
E:inc(x);
S:dec(y);
W:dec(x);
N:inc(y);
end;
inc(i);
end;
assign(t,output.txt);
rewrite(t);
write(t,x, ,y);
close(t);
end.
Пример содержимого input.txt:
FLFS
Пример содержимого output.txt:
1 1
59
Смежные вопросы: