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

为什么会wrong answer.哪位大哥看看吧

Posted by orange at 2003-06-24 22:41:00 on Problem 1146
var s:string;

procedure work(s:string);
var a:array['a'..'z'] of integer;
    len,i,j:integer;
    ch:char;

begin
  fillchar(a,sizeof(a),0);
  len:=length(s);
  ch:=s[len];
  i:=len-1;
  while (i>0) and (ch<=s[i]) do begin
    inc(a[s[i]]);
    dec(i);
  end;
  if i<>0 then inc(a[s[i]]);
  if i=0 then writeln('No Successor')
  else begin
    for j:=1 to i-1 do write(s[j]);
    write(ch);
    for ch:='a' to 'z' do
      while a[ch]<>0 do begin write(ch);dec(a[ch]);end;
    writeln;
  end;
end;

begin
  repeat
    readln(s);
    if s='#' then break;
    work(s);
  until false;
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