|
|
вернуться в форумAC program Послано leo 3 июн 2007 15:24 program spellchecker; var ch:char; state:integer; errors:integer; begin state:=0; errors:=0; while not eof do begin read(ch); case state of 0: begin if ch in ['a'..'z'] then inc(errors); if ch in ['a'..'z']+['A'..'Z'] then state:=1; end; 1: begin if ch in ['A'..'Z'] then inc(errors); if not (ch in ['a'..'z']+['A'..'Z']) then if ch in ['.','!','?'] then state:=0 else state:=2; end; 2: begin if ch in ['a'..'z']+['A'..'Z'] then state:=1; if ch in ['.','!','?'] then state:=0; end; end; end; writeln(errors); end. Re: AC program Послано Oybek 17 окт 2007 17:45 Thanks Realy your program is best AC but my program is WA Can you tell me? Where wrong? My code: "_" is space program_Project2; {$APPTYPE_CONSOLE} uses __SysUtils; var ____ch:char; ____n,i,error:integer; ____a:array[1..10001]_of_char; ____belgi:set_of_char=['.',',',';',':','-','!','?']; ____son:set_of_char=['0'..'9']; ____min:set_of_char=['a'..'z']; ____max:set_of_char=['A'..'Z','_']; begin _____assign(input,''); _____reset(input); _____assign(output,''); _____rewrite(output); _____n:=0; _____error:=0; _____while_not_Eof(input)_do _____begin __________while_not_eoln(input)_do __________begin _______________read(ch); _______________n:=n+1; _______________a[n]:=ch; __________end; __________readln; _____end; _____close(input); _____i:=1; _____while_i<n_do _____begin __________if_((a[i]='.')or(a[i]='!')or(a[i]='?'))and(not_(a[i+1]_in_max))_then __________begin _______________error:=error+1; _______________if_not_(a[i+1]_in_max+min+son+belgi)then_i:=i+2; __________end; __________if_(a[i]<>'_')and(a[i+1]<>'_')_then __________begin _______________if_(a[i]_in_max)and(a[i+1]_in_max)_then_error:=error+1; __________end; __________if_not_(a[i]_in_max+min+son+belgi)_then_error:=error+1; __________i:=i+1; _____end; _____write(error); _____close(output); end. Edited by author 17.10.2007 17:48 Edited by author 17.10.2007 17:49 Re: AC program Послано SHMAK 5 ноя 2007 05:28 2 leo stange but i've written the same structure as you, but Wrong Answer #3 :( Edited by author 05.11.2007 05:29 |
|
|