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. > Когда я отсылаю программу, написанную на 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(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. 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. |