pascal 的一个问题

[复制链接]
查看11 | 回复1 | 2009-9-13 14:40:15 | 显示全部楼层 |阅读模式
这是一个很基本的统计算法主要代码如下:begin readln(n)//长度 for i:=1 to n do
begin
read(ch);//ch为一字符
if ch='T' then begin inc(tt);tf:=0;end
else begin inc(tf);tt:=0; end;
if tt>tmax then tmax:=tt;//tt是T出现的次数,打擂台统计最大
if tf>fmax then fmax:=tf;//tf是F出现的次数,打擂台统计最大
end; writeln(tt);writeln(tf);end. 定义变量你来写吧,很简单
回复

使用道具 举报

千问 | 2009-9-13 14:40:15 | 显示全部楼层
vari,j,x,c:longint;a:array[1..5]of boolean;begina[1]:=true; a[2]:=false; a[3]:=false; a[4]:=true; a[5]:=true;for i:=1 to 5 dobeginc:=1;for j:=i+1 to 5 doif a[j]=a then inc(c) else break;if c>x then x:=c;end;writeln(x);end.应该对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行