题目: |
var
n,ans,i,j: integer;
S: string;
Function get(i: integer) : char;
begin
if i<= n then
get:= s[i]
else get:=s[i-n];
end;
begin readln(s);
n:= length (s);
ans:= 1;
for i:= 2 to n do
begin for j:=0 to n-1 do
if get(i+j) < get(ans+j) then
begin ans:=i;
break;
end
else if get(i+j)> get(ans+j) then
break;
end;
for j:=0 to n-1 do
write(get(ans+j));
writeln;
end.
输入:CBBADADA 输出:ACBBADAD
|