2016年提高组模拟题(20161114) 文件列表

分析:
直接模拟,注意有坑,细心点就AC了。
代码:

var
 s,a:array [1..51] of ansistring;
 n,i,j,k,p:longint;
 e,h:ansistring;
 flag:boolean;

procedure lxf;
 begin
  write('|');
  write('    ');
 end;

procedure wjp;
 begin
  write('|');
  write('----');
 end;

procedure qsort(l,r:longint);
  var
    i,j:longint;
    key,temp:ansistring;
  begin
    if l>=r then exit;
    i:=l;j:=r;
    key:=s[l+random(r-l+1)];
    repeat
      while  (s[i]<key) do inc(i);
      while  (s[j]>key) do dec(j);
      if i<=j then
      begin
        temp:=s[i];s[i]:=s[j];s[j]:=temp;
        inc(i);dec(j);
      end;
    until i>j;
    qsort(l,j);
    qsort(i,r);
  end;


begin
 readln(n);
 for i:=1 to n do
 begin
  readln(s[i]);
  s[i]:=s[i]+'/';
 end;
 qsort(1,n);
 e:=s[1];
 i:=0;
   while pos('/',e)>0 do
    begin
     inc(i);
     p:=pos('/',e);
     h:=copy(e,1,p-1);
     a[i]:=h;
     delete(e,1,p);
     for j:=1 to i-2 do lxf;
     if i>1 then wjp;
     writeln(h);
    end;
 for k:=2 to n do
  begin
   e:=s[k]; i:=0; flag:=true;
   while pos('/',e)>0 do
    begin
     inc(i);
     p:=pos('/',e);
     h:=copy(e,1,p-1);
     delete(e,1,p);
     if a[i]<>h then flag:=false;
     if flag then continue;
     a[i]:=h;
     for j:=1 to i-2 do lxf;
     if i>1 then wjp;
     writeln(h);
    end;
  end;
end.



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值