讨论 / 我这为什么不行,高手们帮看看
没13 2013-08-15 15:28:00
点我顶贴 收藏 删除
program thpone;

var

str:string;

an:array[1..200] of string;

sn,xy,jn:integer;

tt,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z:char;

tn:array[1..27] of integer;

ff:boolean;

begin

readln(str);

for xy:=1 to 27 do tn[xy]:=0;

repeat

ff:=true;

for xy:=1 to length(str)-1 do

if str[xy]>str[xy+1] then

tt:=str[xy];

str[xy]:=str[xy+1];

str[xy+1]:=tt;

ff:=false;

until ff;

for xy:=1 to length(str) do

for jn:=1 to 27 do

case str[xy] of

a,d,g,j,m,p,t,w,’ ’: tn[jn]:=1;

b,e,h,k,n,q,u,x : tn[jn]:=2;

c,f,i,l,o,v,y : tn[jn]:=3;

z : tn[jn]:=4;

end;

for xy:=1 to 27 do

sn:=sn+tn[xy];

write(sn);

readln;

readln;

end.

#1 没13@2008-11-03 17:12:00
回复 删除
case 哪用错拉
#2 qq大QQ@2008-11-15 09:41:00
回复 删除
有必要这么麻烦吗??

直接搜就过了!

例如:

if a[i]=’d’ then ans:=ans+1;

if a[i]=’e’ then ans:=ans+2;

#3 我不是白痴@2010-10-05 13:37:00
回复 删除
应该加' '吧……

#4 0*1@2013-08-15 15:28:00
回复 删除
打表

const

a:array['a'..'z']of 1..4=(1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,1,2,3,4,1,2,3,1,2,3,4);

var

ch:char;

s:integer;

begin

while not eof do

begin

read(ch);

if ch<>' ' then s:=s+a[ch]

else inc(s);

end;

readln;

writeln(s);

end.

查看更多回复
提交回复