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

我的程序老是WA,请高手帮忙看一下!

Posted by baiguihong at 2004-11-23 21:12:35 on Problem 1002
program p1002;
const ttt:array['A'..'Z'] of integer=(2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9);
var t:array[1..1200] of longint;
    n,pp,i:longint;
   cm:string;


 procedure out(k,num:longint);
 var  s1,s:string;
     d,l:longint;
 begin
  s1:='';
  s:='';
  str(k,s1);
  while length(s1)<7 do  s1:=' '+s1;
  s:=copy(s1,1,3)+'-'+copy(s1,4,4)+' ';
  writeln(s,num);
 end;

procedure init;
var i,j,k,l:longint;
   cmd:string[100];
begin
 cm:='No duplicates.';
 readln(n);
 pp:=0;
  fillchar(t,sizeof(t),0);
  cmd:='';
 for i:=1 to n do 
 begin
  readln(cmd);
   j:=0;
  
   k:=0;l:=length(cmd);
   repeat
    inc(j);
    if cmd[j]='-' then continue;
     k:=k*10;
     if cmd[j] in ['0'..'9'] then 
        k:=k+ord(cmd[j])-48
        else k:=k+ttt[cmd[j]];

   until j>=l;
   inc(pp);
   t[pp]:=k;
  
 end;
 randomize;
end; 

 procedure qsort(i,j:longint);
 var med,nj,ni,k:longint;
 begin
   ni:=i; nj:=j;
   med:=t[(i+j) div 2];

  repeat
   while t[ni]<med do ni:=ni+1;
   while t[nj]>med do nj:=nj-1;
   if ni<=nj then
    begin
      k:=t[ni];t[ni]:=t[nj];t[nj]:=k;
       inc(ni);  dec(nj);
     end;
 until ni>nj;
 if i<nj then qsort(i,nj);
 if j> ni then qsort(ni,j);
 end;
  procedure main;
  var i,j,k:longint;
    ans:boolean;
   begin
   ans:=false;
   i:=0;j:=0;
    repeat
     inc(i);
     if t[i]<>t[i+1] then begin
       if j<>0 then begin ans:=true;out(t[i],j+1);end;
       j:=0;
      end
       else inc(j);
    until i=n;    


   if not ans then begin
   writeln(cm);

    end;
    end;
 begin
init;
 i:=0;
 while (t[i]<t[i+1]) or (t[i]=t[i+1]) do inc(i);
 if i<>n+1 then qsort(1,n);
 main;  
 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