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.

转载于:https://www.cnblogs.com/love-saber/p/5933001.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值