首页 > 代码库 > noi4_1_1754[字符串数组排序问题]
noi4_1_1754[字符串数组排序问题]
没忽略空格竟AC
var way:string;
a,b:array[1..100000] of string;
n:longint;
function cl(a,b:string):boolean;
begin
if (way=‘inc‘)or(way=‘dec‘) then exit(a>b);
exit(lowercase(a)>lowercase(b))
end;
procedure scanf;
var i:longint;
begin
readln(way);
readln(n);
for i:=1 to n do
readln(a[i]);
end;
procedure sort;
var i,j:longint;
tmp:string;
begin
b:=a;
for i:=1 to n-1 do
for j:=i+1 to n do
if cl(b[i],b[j]) then
begin
tmp:=b[i];
b[i]:=b[j];
b[j]:=tmp;
end;
a:=b;
if (way=‘dec‘)or(way=‘ncdec‘) then
begin
for i:=1 to n do
a[i]:=b[n+1-i];
end;
end;
procedure printf;
var i:longint;
begin
for i:=1 to n do
writeln(a[i]);
end;
begin
scanf;
sort;
printf;
end.
noi4_1_1754[字符串数组排序问题]
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。