码迷,mamicode.com
首页 > 编程语言 > 详细

noi4_1_1754[字符串数组排序问题]

时间:2016-10-05 22:05:34      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

没忽略空格竟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[字符串数组排序问题]

标签:

原文地址:http://www.cnblogs.com/love-saber/p/5933001.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!