如果发现广告等破坏行为,请尽量将条目恢复到较早的版本而不是把相应内容直接删除,谢谢合作。
URAL/1094
来自"NOCOW"
< URAL
字符串处理
#include <iostream> using namespace std; long i; long now; char a[100]; char s[10010]; int main () { for (i=0;i<80;i++) a[i]=' '; cin.getline (s,10010); for (i=0;i<strlen(s);i++) { if (s[i]=='<') { now--; if (now==-1) now=0; continue; } if (s[i]=='>') { now++; if (now==80) now=0; continue; } a[now]=s[i]; now++; if (now==80) now=0; } for (i=0;i<80;i++) cout<<a[i]; cout<<endl; return (0); }
pascal版:
program cyd; var d:array[0..80]of char; i,j,k,l,m,n,a,b,now:longint; c:char; begin for i:=0 to 79 do d[i]:=' '; now:=0; while not eof do begin read(c); if (ord(c)=13)or(ord(c)=10) then continue; if c='>' then begin inc(now); if now=80 then now:=0; continue; end; if c='<' then begin dec(now); if now=-1 then now:=0; continue; end; d[now]:=c; inc(now); if now=80 then now:=0; end; for i:=0 to 79 do write(d[i]); end.