Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:牛们来看看……本菜WA了……In Reply To:牛们来看看……本菜WA了…… Posted by:skywalker_q at 2009-07-29 22:09:46 > const > list:array['A'..'Z']of char= > ('2','2','2','3','3','3','4', > '4','4','5','5','5','6','6', > '6','7','-','7','7','8','8', > '8','9','9','9','-'); > > var > n:longint; > a:array[1..100000]of longint; > > procedure init; > var > i,j,l:longint; > s:string; > begin > readln(n); > for i:=1 to n do > begin > readln(s); > l:=length(s); > for j:=1 to l do > if s[j] in ['A'..'Z'] then > s[j]:=list[s[j]]; > a[i]:=0; > for j:=1 to l do > if s[j] in ['0'..'9'] then > a[i]:=a[i]*10+ord(s[j])-48; > end; > randomize; > end; > > procedure qsort(l,r:longint); > var > i,j,x,temp:longint; > begin > i:=l; j:=r; > x:=a[l+random(r-l+1)]; > repeat > while a[i]<x do inc(i); > while a[j]>x do dec(j); > if i<=j then > begin > temp:=a[i]; > a[i]:=a[j]; > a[j]:=temp; > inc(i); > dec(j); > end; > until i>j; > if l<j then qsort(l,j); > if i<r then qsort(i,r); > end; > > procedure print; > var > flag:boolean; > i,count,last:longint; > begin > flag:=false; > last:=a[1]; > count:=1; > for i:=2 to n do > begin > if a[i]=last then > begin > inc(count); > continue; > end > else > begin > if count>1 then > begin > writeln(last div 10000,'-',last mod 10000,' ',count); > flag:=true; > end; > count:=1; > last:=a[i]; > end; > end; > if not flag then writeln('No duplicates'); > end; > > begin > init; > qsort(1,n); > print; > end. 到底错哪里了? Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator