|
|
back to boardHelp! I got WA! var tmp:string; ch:char; j:integer; begin tmp:=''; while not eof do begin read(ch); if ch in ['A'..'z'] then begin tmp:=tmp+ch; end else begin for j:=length(tmp) downto 1 do write(tmp[j]); write(ch); tmp:=''; end; end; end. See my solution on this webboard i got AC. Can you chack my anather programs on webboard This will Help! Posted by JL Wang 19 Nov 2002 20:09 > var tmp:string; > ch:char; > j:integer; > begin > tmp:=''; > while not eof do > begin > read(ch); > if ch in ['A'..'z'] then > begin > tmp:=tmp+ch; > end > else > begin > for j:=length(tmp) downto 1 do write(tmp[j]); > write(ch); > tmp:=''; > end; > end; > end. Hey, man! There's two mistakes in your program: 1.There's a lot of other symbol (not letter) between 'A'..'Z' and 'a'..'z' in ASCII order. So do use set ['A'..'Z','a'..'z'] instead of set ['A'..'z']. 2.If the input ends by a letter not a symbol, your program will not output the last word. PS: If you still don't understand, see my solution below, it is an AC one. But i got AC > > var tmp:string; > > ch:char; > > j:integer; > > begin > > tmp:=''; > > while not eof do > > begin > > read(ch); > > if ch in ['A'..'z'] then > > begin > > tmp:=tmp+ch; > > end > > else > > begin > > for j:=length(tmp) downto 1 do write(tmp[j]); > > write(ch); > > tmp:=''; > > end; > > end; > > end. > > > > Hey, man! There's two mistakes in your program: > 1.There's a lot of other symbol (not letter) between 'A'..'Z' > and 'a'..'z' in ASCII order. So do use set ['A'..'Z','a'..'z'] > instead of set ['A'..'z']. > 2.If the input ends by a letter not a symbol, your program will not > output the last word. > > PS: If you still don't understand, see my solution below, it is an AC > one. |
|
|