求助,贝贝的单词游戏,用free pascal语言 10
展开全部
你没给数据
不知道对不对
你看看思路吧
var i,n,k,j:longint;
standard:char;
s:array[1..30] of string;
new_s:array[1..30] of string;
function sgn(n:longint):longint;
begin
if n<0 then exit(-1);
if n>0 then exit(1);
exit(0);
end;
function get(k:longint;var ch:char):char;
var i:longint;
begin
case sgn(k) of
1: for i:=0 to k do
case ch of
'z': ch:='a';
else
ch:=succ(ch);
end;
-1: for i:=0 downto k do
case ch of
'a': ch:='z';
else
ch:=pred(ch);
end;
end;
exit(ch);
end;
function read_word():string;
var ch:char;
s:string;
begin
read(ch);
while ch<>' ' do
begin
s:=s+ch;
read(ch);
end;
end;
begin
readln(standard);
readln(n);
for i:=1 to n do
begin
s[i]:=read_word();
readln(k);
for j:=1 to length(s[i]) do
insert(get(k,s[i][j]),new_s[i],j);
end;
k:=0;
for i:=1 to n do
for j:=1 to length(new_s[i]) do
if new_s[i][j]=standard then inc(k);
writeln(k);
end.
不知道对不对
你看看思路吧
var i,n,k,j:longint;
standard:char;
s:array[1..30] of string;
new_s:array[1..30] of string;
function sgn(n:longint):longint;
begin
if n<0 then exit(-1);
if n>0 then exit(1);
exit(0);
end;
function get(k:longint;var ch:char):char;
var i:longint;
begin
case sgn(k) of
1: for i:=0 to k do
case ch of
'z': ch:='a';
else
ch:=succ(ch);
end;
-1: for i:=0 downto k do
case ch of
'a': ch:='z';
else
ch:=pred(ch);
end;
end;
exit(ch);
end;
function read_word():string;
var ch:char;
s:string;
begin
read(ch);
while ch<>' ' do
begin
s:=s+ch;
read(ch);
end;
end;
begin
readln(standard);
readln(n);
for i:=1 to n do
begin
s[i]:=read_word();
readln(k);
for j:=1 to length(s[i]) do
insert(get(k,s[i][j]),new_s[i],j);
end;
k:=0;
for i:=1 to n do
for j:=1 to length(new_s[i]) do
if new_s[i][j]=standard then inc(k);
writeln(k);
end.
展开全部
查不到这个题目。请你将题目贴上来吧
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
呃
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
题目呢????
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询