把一个字符串按照特定的符号分成5分,把后四份按照特定的顺序插入后一个字符串的‘...’处,最后将去掉符号的字符串输出即可。
![](https://i-blog.csdnimg.cn/blog_migrate/8f900a89c6347c561fdf2122f13be562.gif)
![](https://i-blog.csdnimg.cn/blog_migrate/961ddebeb323a10fe0623af514929fc1.gif)
1 program pku1917(input,output); 2 var 3 s : array[0..6] of ansistring; 4 ss,x : ansistring; 5 cases : longint; 6 i,tmp : longint; 7 begin 8 readln(cases); 9 while cases>0 do 10 begin 11 dec(cases); 12 readln(ss); 13 x:=ss; 14 15 while pos('<',x)>0 do 16 delete(x,pos('<',x),1); 17 while pos('>',x)>0 do 18 delete(x,pos('>',x),1); 19 20 for i:=1 to 5 do 21 s[i]:=''; 22 23 tmp:=pos('<',ss); 24 s[1]:=copy(ss,1,tmp-1); 25 delete(ss,1,tmp); 26 27 tmp:=pos('>',ss); 28 s[2]:=copy(ss,1,tmp-1); 29 delete(ss,1,tmp); 30 31 tmp:=pos('<',ss); 32 s[3]:=copy(ss,1,tmp-1); 33 delete(ss,1,tmp); 34 35 tmp:=pos('>',ss); 36 s[4]:=copy(ss,1,tmp-1); 37 delete(ss,1,tmp); 38 39 s[5]:=ss; 40 41 s[0]:=s[4]+s[3]+s[2]+s[5]; 42 43 readln(ss); 44 tmp:=pos('...',ss); 45 insert(s[0],ss,tmp); 46 tmp:=pos('...',ss); 47 delete(ss,tmp,3); 48 writeln(x); 49 writeln(ss); 50 end; 51 end.