谁帮我看看啊…………哪儿错

var n,flag,i,j,k:longint;

c:char;

s,temp1,temp2:string;

word:array[0..100] of string;

shun:array['a'..'z'] of longint;

begin

read(s,n);

for i:=1 to n do

begin

readln;

while not(eoln) do

begin

read(c) ;

word[i]:=word[i]+c;

end;

end;

read(flag);

if flag=1 then for i:=1 to 26 do shun[s[i]]:=i

else for i:=1 to 26 do shun[s[i]]:=27-i;

for i:=1 to n-1 do

for j:=1 to n-i do

begin

temp1:=word[j];temp2:=word[j+1];

k:=1;

while temp1[k]=temp2[k] do inc(k);

if shun[temp1[k]]>shun[temp2[k]]

then begin word[0]:=word[j];word[j]:=word[j+1];word[j+1]:=word[0];end;

end;

for i:=1 to n-1 do writeln(word[i]);

write(word[n]);

end.

0 条评论

目前还没有评论...

信息

ID
1500
难度
6
分类
字符串 | 其他 | 排序 点击显示
标签
递交数
2884
已通过
721
通过率
25%
被复制
3
上传者