• Нельзя преобразовать тип 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.

Ответы 1

  • //Не смотрел Ваш код, просто моё видение решения задачи//PascalABC.NET 3.2 сборка 1318Var  t:text;  x,y,i,j:integer;  s:string;  c:char;  world:array[1..4] of char=('E','S','W','N');beginj:=1;c:='E';assign(t,'input.txt');reset(t);read(t,s);close(t);i:=1;while s[i]<>'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
    • Автор:

      alma
    • 5 лет назад
    • 0
  • Добавить свой ответ

Войти через Google

или

Забыли пароль?

У меня нет аккаунта, я хочу Зарегистрироваться

How much to ban the user?
1 hour 1 day 100 years