我自己写了一个函数:
function calculateb(s:string):string;
var a,b,c,d:real;
m:array[1..6] of real;
i:integer;
n:string;
begin
a:=1;
b:=1.5;
c:=(a+b)/5;
d:=strtofloat(s);
if d>=b then
begin
m[1]:=1;
for i:=2 to 6 do
begin
m[i]:=0;
end;
end
else
if d<a then
begin
m[6]:=1;
for i:=1 to 5 do
begin
m[i]:=0;
end;
end
else
for i:=1 to 6 do
begin
if (b-i*c)<=d<(b-(i-1)*c) then//这个地方出现了一个错误[Error] Unit4.pas(462): incompatible types begin
m[i]:=(d-(b-i*c))/c;
m[i+1]:=((b-(i-1)*c)-d)/c;
end
else
begin
m[i]:=0;
end;
end;
for i:=1 to 6 do
begin
n:=n+floattostr(m[i])+',';
end;
result:=n;
end;
请问应该怎么样解决啊?
function calculateb(s:string):string;
var a,b,c,d:real;
m:array[1..6] of real;
i:integer;
n:string;
begin
a:=1;
b:=1.5;
c:=(a+b)/5;
d:=strtofloat(s);
if d>=b then
begin
m[1]:=1;
for i:=2 to 6 do
begin
m[i]:=0;
end;
end
else
if d<a then
begin
m[6]:=1;
for i:=1 to 5 do
begin
m[i]:=0;
end;
end
else
for i:=1 to 6 do
begin
if (b-i*c)<=d<(b-(i-1)*c) then//这个地方出现了一个错误[Error] Unit4.pas(462): incompatible types begin
m[i]:=(d-(b-i*c))/c;
m[i+1]:=((b-(i-1)*c)-d)/c;
end
else
begin
m[i]:=0;
end;
end;
for i:=1 to 6 do
begin
n:=n+floattostr(m[i])+',';
end;
result:=n;
end;
请问应该怎么样解决啊?
解决方案 »
- Delphi DxBarManager 菜单控件问题
- delphi7版本以及前有能够实现所见即所得的html编辑功能的吗?
- 一個scroll 控制兩個grid同步滾動,請問代碼如何寫 急
- cxgrid如何允许用户分组,在取消分组把列标题拖回后恢复原先的排列顺序?
- 超郁闷的一个问题,关于剪贴板...望高手救救..
- 如何在某個區間得到隨機數,比如10-36這個區間得到隨機數?
- 在向listview中添加一条记录后,第一列有一个checkbox,如何去掉呀!!!!!!!!!
- 小问题:远程桌面数据库访问原理?
- 请问哪儿有dbgrid的控件下载,可以重排里面的内容,按照时间或名称或id.
- 高难问题
- 各位高手,谁对nil有研究,请教isnull()的用法
- 为什么在delphi7的new items中的forms中没了quickreport labels这一项啊,对着6.0的书看,用的是7.0的delphi啊!
这句语法写错了吧!你这句等效于((b-i*c)<=d)<(b-(i-1)*c)
这样((b-i*c)<=d)结果是个布尔值,(b-(i-1)*c)是一个Real值,当然会出现类型不匹配了