讨论 / HELP!!第二个点??
海的翅膀 2008-07-28 06:17:00
点我顶贴 收藏 删除
测试结果1: 测试结果正确

测试结果2:

测试结果3: 测试结果正确

测试结果4: 测试结果错误.错误结果为:ONMLKJIHGFEDCBA

IJKLMNOGFEDCBA

IJKLMNOFEDCBA

NMLKJIFEDCBA

NMLKJIFEDCB

JKLMNFEDCB

KLMNFEDCB

正确结果应为:ONMLKJIHGFEDCBA

IJKLMNOGFEDCBA

IJKLMNOABCDEF

NMLKJIABCDEF

NMLKJIFEDCB

JKLMNFEDCB

KLMNFEDCB

测试结果5: 测试结果错误.错误结果为:ABCDEFGHIJKLMNOPQRSTUVWXYZ

DCBAFGHIJKLMNOPQRSTUVWXYZ

DCBAFGHIJKLMNPQRSTUVWXYZ

DBAFGHIJKLMNPQRSTUVWXYZ

LKJIHGFABDNPQRSTUVWXYZ

BAFGHIJKLNPQRSTUVWXYZ

LKJIHGFABPQRSTUVWXYZ

KJIHGFABPQRSTUVWXYZ

KJIHGFABPQRTUVWXYZ

BAFGHIJKQRTUVWXYZ

ABGHIJKQRTUVWXYZ

BGHIJKQRTUVWXYZ

BHIJKQRTUVWXYZ

BIJKQRTUVWXYZ

RQKJIBUVWXYZ

RQKJIBUVWXZ

RQKJIBUVWX

RQKJIBUVW

RQKJIUVW

RKJIUVW

RKJIUV

RKJUV

KRUV

KUV

UV

V

正确结果应为:ABCDEFGHIJKLMNOPQRSTUVWXYZ

DCBAFGHIJKLMNOPQRSTUVWXYZ

DCBAFGHIJKLMNZYXWVUTSRQP

DBAFGHIJKLMNZYXWVUTSRQP

LKJIHGFABDNZYXWVUTSRQP

BAFGHIJKLNZYXWVUTSRQP

LKJIHGFABZYXWVUTSRQP

KJIHGFABZYXWVUTSRQP

KJIHGFABZYXWVUTPQR

KJIHGFABZYXWVUTRQ

GHIJKABZYXWVUTRQ

KJIHGBZYXWVUTRQ

HIJKBZYXWVUTRQ

IJKBZYXWVUTRQ

IJKBZYXWVUQR

ZBKJIXWVUQR

BKJIXWVUQR

IJKBWVUQR

KJIWVUQR

KJIWVUR

IJKVUR

JKVUR

KVUR

KVU

VU

V

测试结果6:

测试结果7: 测试结果正确

测试结果8:

测试结果9: 测试结果错误.错误结果为:ONMLKJIHGFEDCBA

IJKLMNOGFEDCBA

IJKLMNOFEDCBA

NMLKJIFEDCBA

NMLKJIFEDCB

JKLMNFEDCB

KLMNFEDCB

正确结果应为:ONMLKJIHGFEDCBA

IJKLMNOGFEDCBA

IJKLMNOABCDEF

NMLKJIABCDEF

NMLKJIFEDCB

JKLMNFEDCB

KLMNFEDCB

测试结果10: 测试结果正确

提交代码: Program P78;

Type

Tn = 0..26;

Var

s : String;

n : Tn;

////////////////////////////////

Procedure Work(l : Tn; c : Char);

Var

i, t, j : Tn;

s1 : String;

Begin

For i:=1 To l Do

If s[i] = c

Then

Break;

If i - 1 <= l - i

Then

Begin

s1 := Copy(s, 1, i - 1);

t := i - 1;

j := 1;

While t > 0 Do

Begin

s[j] := s1[t];

Inc(j);

Dec(t)

End

End

Else

Begin

s1 := Copy(s, i + 1, l - i);

t := t - i;

j := i + 1;

While t > i Do

Begin

s[j] := s1[t];

Inc(j);

Dec(t)

End

End;

s1 := Copy(s, 1, i - 1) + Copy(s, i + 1, l - i);

s := s1;

Writeln(s);

End;

////////////////////////////////

Procedure Init;

Var

i, l : Tn;

c : Char;

Begin

Readln(s);

Writeln(s);

l := Length(s);

Readln(n);

For i :=1 To n Do

Begin

Readln(c);

Work(l, c);

Dec(l)

End

End;

////////////////////////////////

Begin

Init

End.

#1 vinence@2008-07-28 06:17:00
回复 删除
var

ls:char;

a:string;

a1:array[1..26] of char;

n,i,len,mid,xx:integer;

procedure try(a2:char);

var

j,k:integer;

b:array[1..26] of char;

begin

j:=0;

while a2<>a1[j] do inc(j);

if j<=mid then

begin

for k:=1 to j-1 do

b[k]:=a1[k];

for k:=j downto 2 do

a1[k]:=b[j+1-k];

for k:=1 to len-1 do

a1[k]:=a1[k+1];

len:=len-1;

end;

if j>mid then

begin

for k:=j+1 to len do

b[k]:=a1[k];

for k:=j to len-1 do

a1[k]:=b[j+len-k];

len:=len-1;

end;

end;

begin

readln(a);

writeln(a);

len:=length(a);

for i:=1 to len do a1[i]:=a[i];

readln(n);

for i:=1 to n do

begin

readln(ls);

if len mod 2 =1 then mid:=(len+1) div 2 else mid:=len div 2;

try(ls);

for xx:=1 to len do

write(a1[xx]);

writeln;

end;

end.

查看更多回复
提交回复