ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Моя программа не работает.
Posted by Hawk 22 Jan 2003 21:09
Когда я отсылаю программу, написанную на Borland Pascal'е, то получаю сообщение следующего содержания: "Problem field contains invalid data". У меня в BP все компилируется нормально.
Исходник программы:
uses
 crt;
var
 f: text;
function wordin(x:string):string;
 var
  buf,i: byte;
 begin
  buf:=0;
  for i:=1 to length(x)-1 do
   if x[i]=' ' then buf:=i;
  if buf=0 then
   wordin:=copy(x,1,length(x)-1)
  else
   wordin:=copy(x,buf+1,length(x)-1);
 end;
procedure readzna(fname:string);
 var
  x: string;
 begin
  x:='';
  assign(f,fname);
  rewrite(f);
  while x<>'-1' do
   begin
    readln(x);
    if x<>'-1' then
     writeln(f,x);
   end;
  close(f);
 end;
procedure delword(word:string;var f:text);
 var
  d          : text;
  buf,buf1   : string;
 begin
  reset(f);
  assign(d,'tmp');
  rewrite(d);
  buf:='';
  while not eof(f) do
   begin
    readln(f,buf);
    if buf<>word then
     writeln(d,buf)
    else
     if not eof(f) then
      begin
       readln(f,buf1);
       writeln(d,buf1);
      end;
   end;
  close(f);
  close(d);
  reset(d);
  rewrite(f);
  while not eof(d) do
   begin
    readln(d,buf);
    writeln(f,buf);
   end;
  erase(d);
  reset(f);
  buf:='';
  while buf<>buf1 do
   begin
    readln(f,buf);
   end;
 end;
function wordtonum(a:string):string;
 var
  i     : byte;
  ch    : char;
  z     : string;
 begin
  z:='';
  for i:=1 to length(a) do
   begin
    ch:=a[i];
    case ch of
     'i','j': z:=z+'1';
     'a','b','c': z:=z+'2';
     'd','e','f': z:=z+'3';
     'g','h': z:=z+'4';
     'k','l': z:=z+'5';
     'm','n': z:=z+'6';
     'p','r','s': z:=z+'7';
     't','u','v': z:=z+'8';
     'w','x','y': z:=z+'9';
     'o','q','z': z:=z+'0';
    end;
   end;
  wordtonum:=z;
 end;
procedure convert(fname:string);
 var
  g             : text;
  a,b,ab,obz,max: string;
  i,x           : longint;
  find          : boolean;
 begin
  max:='';
  assign(f,fname);
  reset(f);
  a:='';
  while not eof(f) do
  begin
   x:=0;
   readln(f,a);
   ab:=a;
   obz:='';
   readln(f,x);
   assign(g,'phone.tmp');
   rewrite(g);
   for i:=1 to x do
    begin
     readln(f,b);
     writeln(g,b);
    end;
   close(g);
   find:=false;
   while not(find) do
    begin
     reset(g);
     max:='';
     while not(eof(g)) do
      begin
       readln(g,b);
       if pos(wordtonum(b),ab)=1 then
        if length(b)>length(max) then max:=b;
      end;
     close(g);
     if max<>'' then
      begin
       if length(max)<>length(ab) then
        begin
         obz:=obz+max+' ';
         delete(ab,1,length(max));
Don't use USES CRT; AND FINES.
Posted by I am david. Tabo. 22 Jan 2003 21:50
> &#1050;&#1086;&#1075;&#1076;&#1072; &#1103; &#1086;&#1090;&#1089;&#1099;&#1083;&#1072;&#1102; &#1087;&#1088;&#1086;&#1075;&#1088;&#1072;&#1084;&#1084;&#1091;, &#1085;&#1072;&#1087;&#1080;&#1089;&#1072;&#1085;&#1085;&#1091;&#1102; &#1085;&#1072; Borland Pascal'&#1077;, &#1090;&#1086;
&#1087;&#1086;&#1083;&#1091;&#1095;&#1072;&#1102; &#1089;&#1086;&#1086;&#1073;&#1097;&#1077;&#1085;&#1080;&#1077; &#1089;&#1083;&#1077;&#1076;&#1091;&#1102;&#1097;&#1077;&#1075;&#1086; &#1089;&#1086;&#1076;&#1077;&#1088;&#1078;&#1072;&#1085;&#1080;&#1103;: "Problem field contains
invalid data". &#1059; &#1084;&#1077;&#1085;&#1103; &#1074; BP &#1074;&#1089;&#1077; &#1082;&#1086;&#1084;&#1087;&#1080;&#1083;&#1080;&#1088;&#1091;&#1077;&#1090;&#1089;&#1103; &#1085;&#1086;&#1088;&#1084;&#1072;&#1083;&#1100;&#1085;&#1086;.
> &#1048;&#1089;&#1093;&#1086;&#1076;&#1085;&#1080;&#1082; &#1087;&#1088;&#1086;&#1075;&#1088;&#1072;&#1084;&#1084;&#1099;:
> uses
>  crt;
> var
>  f: text;
> function wordin(x:string):string;
>  var
>   buf,i: byte;
>  begin
>   buf:=0;
>   for i:=1 to length(x)-1 do
>    if x[i]=' ' then buf:=i;
>   if buf=0 then
>    wordin:=copy(x,1,length(x)-1)
>   else
>    wordin:=copy(x,buf+1,length(x)-1);
>  end;
> procedure readzna(fname:string);
>  var
>   x: string;
>  begin
>   x:='';
>   assign(f,fname);
>   rewrite(f);
>   while x<>'-1' do
>    begin
>     readln(x);
>     if x<>'-1' then
>      writeln(f,x);
>    end;
>   close(f);
>  end;
> procedure delword(word:string;var f:text);
>  var
>   d          : text;
>   buf,buf1   : string;
>  begin
>   reset(f);
>   assign(d,'tmp');
>   rewrite(d);
>   buf:='';
>   while not eof(f) do
>    begin
>     readln(f,buf);
>     if buf<>word then
>      writeln(d,buf)
>     else
>      if not eof(f) then
>       begin
>        readln(f,buf1);
>        writeln(d,buf1);
>       end;
>    end;
>   close(f);
>   close(d);
>   reset(d);
>   rewrite(f);
>   while not eof(d) do
>    begin
>     readln(d,buf);
>     writeln(f,buf);
>    end;
>   erase(d);
>   reset(f);
>   buf:='';
>   while buf<>buf1 do
>    begin
>     readln(f,buf);
>    end;
>  end;
> function wordtonum(a:string):string;
>  var
>   i     : byte;
>   ch    : char;
>   z     : string;
>  begin
>   z:='';
>   for i:=1 to length(a) do
>    begin
>     ch:=a[i];
>     case ch of
>      'i','j': z:=z+'1';
>      'a','b','c': z:=z+'2';
>      'd','e','f': z:=z+'3';
>      'g','h': z:=z+'4';
>      'k','l': z:=z+'5';
>      'm','n': z:=z+'6';
>      'p','r','s': z:=z+'7';
>      't','u','v': z:=z+'8';
>      'w','x','y': z:=z+'9';
>      'o','q','z': z:=z+'0';
>     end;
>    end;
>   wordtonum:=z;
>  end;
> procedure convert(f
Re: Don't use USES CRT; AND FINES.
Posted by Hawk 23 Jan 2003 11:52
I delete uses crt string, but my program not work in any way. I alway get message, that problem field has invalid data! Please help.
I chack your program. see it but i don't know that it is worcking.
Posted by I am david. Tabo. 23 Jan 2003 20:31
function wordin(x:string):string;
 var
  buf,i: byte;
 begin
  buf:=0;
  for i:=1 to length(x)-1 do
   if x[i]=' ' then buf:=i;
  if buf=0 then
   wordin:=copy(x,1,length(x)-1)
  else
   wordin:=copy(x,buf+1,length(x)-1);
 end;
procedure readzna;
 var
  x: string;
 begin
  x:='';
  while x<>'-1' do
   begin
    readln(x);
    if x<>'-1' then
     writeln(x);
   end;
 end;
procedure delword(word:string;var f:text);
 var
  d          : text;
  buf,buf1   : string;
 begin
  reset(f);
  assign(d,'tmp');
  rewrite(d);
  buf:='';
  while not eof(f) do
   begin
    readln(f,buf);
    if buf<>word then
     writeln(d,buf)
    else
     if not eof(f) then
      begin
       readln(f,buf1);
       writeln(d,buf1);
      end;
   end;
  close(f);
  close(d);
  reset(d);
  rewrite(f);
  while not eof(d) do
   begin
    readln(d,buf);
    writeln(f,buf);
   end;
  erase(d);
  reset(f);
  buf:='';
  while buf<>buf1 do
   begin
    readln(f,buf);
   end;
 end;
function wordtonum(a:string):string;
 var
  i     : byte;
  ch    : char;
  z     : string;
 begin
  z:='';
  for i:=1 to length(a) do
   begin
    ch:=a[i];
    case ch of
     'i','j': z:=z+'1';
     'a','b','c': z:=z+'2';
     'd','e','f': z:=z+'3';
     'g','h': z:=z+'4';
     'k','l': z:=z+'5';
     'm','n': z:=z+'6';
     'p','r','s': z:=z+'7';
     't','u','v': z:=z+'8';
     'w','x','y': z:=z+'9';
     'o','q','z': z:=z+'0';
    end;
   end;
  wordtonum:=z;
 end;
procedure convert;
 var
  g             : text;
  a,b,ab,obz,max: string;
  i,x           : longint;
  find          : boolean;
 begin
  max:='';
  a:='';
  while not eof do
  begin
   x:=0;
   readln(a);
   ab:=a;
   obz:='';
   readln(x);
   for i:=1 to x do
    begin
     readln(b);
     writeln(b);
    end;
   close(g);
   find:=false;
   while not(find) do
    begin
     max:='';
     while not(eof) do
      begin
       readln(b);
       if pos(wordtonum(b),ab)=1 then
        if length(b)>length(max) then max:=b;
      end;
     close(g);
     if max<>'' then
      begin
       if length(max)<>length(ab) then
        begin
         obz:=obz+max+' ';
         delete(ab,1,length(max));
         delword(max,g);
        end
      else
       begin
        obz:=obz+max;
        writeln(obz);
        find:=true;
       end;
      end
     else
      begin
       if obz='' then
        begin
         writeln('No Solution');
         find:=true;
        end
       else
        begin
         delword(wordin(obz),g);
         obz:='';
        end;
      end;
    end;
  end;
 end;
begin
 readzna;
 convert;
end.