Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

一个PASCAL的代码,不用排序

Posted by demaxiya at 2012-08-21 15:13:23 on Problem 2159
var
s,j:string;
a,b:array [0..100] of byte;
c,d:array ['A'..'Z'] of integer;
bb:boolean;
p:char;
i,t,k,n:integer;
begin
readln(s);
readln(j);
if length(s)<>length(j) then begin writeln('NO');exit; end;
k:=length(s);
for i:=1 to k do inc(c[s[i]]);
for i:=1 to k do inc(d[j[i]]);

for i:=1 to 26 do
inc(a[c[chr(ord('A')-1+i)]]);
for i:=1 to 26 do
inc(b[d[chr(ord('A')-1+i)]]);
bb:=true;
for i:=1 to 100 do if a[i]<>b[i] then bb:=false;
if bb then writeln('YES')
      else writeln('NO');
end.

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator