这题字符串处理
注意Seekeof会自动把后面的空格吃掉(有时遇到回车,后面会漏一个空格……貌似有时没空格也会读到,字符串处理时慎用)
另外 空格的Ascii码是32,31及以下都是不可输入字符
program P2271;
var
s:string;
procedure cin;
var
c:char;
i,len:longint;
begin
s:='';
c:=' ';
i:=0;
while not(seekeof) do
begin
read(c);
while (ord(c)<=32) and not(eof) do read(c);
if ord(c)<=32 then break;
repeat
s:=s+c;
if eof then break;
read(c);
until (ord(c)<=32);
len:=length(s);
if s='<br>' then begin writeln; i:=0; end
else
if s='<hr>' then
begin
if i>0 then writeln;
for i:=1 to 80 do write('-');
writeln;
i:=0;
end
else
begin
if (i=0) then
begin
if len<80 then
begin
write(s);
i:=len;
end;
end
else
begin
if (i+1+len<=80) then
begin
write(' ',s);
i:=i+1+len;
end
else
begin
writeln;
write(s);
i:=len;
end;
end;
end;
s:='';
end;
end;
begin
{ assign(input,'p2271.in');
assign(output,'p2271.out');
reset(input);
rewrite(output);
} cin;
writeln;
{ close(input);
close(output);}
end.
分享到:
相关推荐
POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类POJ分类
poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题报告poj 解题...
POJ第1861题源码 POJ第1861题源码 POJ第1861题源码
poj分类poj分类poj分类poj分类
北大POJ1159-Palindrome 解题报告+AC代码
poj 3414解题报告poj 3414解题报告poj 3414解题报告poj 3414解题报告
poj 1012解题报告poj 1012解题报告poj 1012解题报告poj 1012解题报告
poj 2329解题报告poj 2329解题报告poj 2329解题报告poj 2329解题报告
poj 1659解题报告poj 1659解题报告poj 1659解题报告poj 1659解题报告
C语言 poj npu 西工大 C语言Poj答案全完整打包,给有需要的朋友
POJ1503解答 POJ1503解答,正确答案(已通过POJ)
POJ1083的代码,POJ1083的代码,POJ1083的代码
poj 百练 题目分类 poj 百练 题目分类
POJ1048,加强版的约瑟夫问题 难度中等
北大POJ2002-Squares 解题报告+AC代码
poj 1001答案
POJ2968代码有用,欢迎下载,POJ代码
poj 1440解题报告 poj 1440解题报告 poj 1440解题报告 poj 1440解题报告
poj 3083解题报告poj 3083解题报告poj 3083解题报告poj 3083解题报告
北大POJ2305-Basic remains POJ2305-Basic remains