begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
for k:=1 to 8 do
begin
for i:=1 to 8 do
begin
y=sum1(infoID[i],k)/10
......
在调用时老是提示出错,请懂的大哥指教下,不胜感激
20 个解决方案
#1
先把这一句y=sum1(infoID[i],k)/10 注释掉试试,看还错不错?
#2
1楼的大哥,你说的什么意思,不太懂,y=sum1(infoID[i],k)/10 这句我漏写了个:,加上也还是不行。
#3
其实问题也就是如何调用具有两个输入参数的函数
#4
单步跟踪,调试一下吧。
#5
4楼的大哥,我想我调用的格式可能不对,但不知道怎么改
#6
你传入的参数类型和Sum1函数的原型说明是否一致?
#7
递归?
#8
infoID[i]是什么,怎样定义的,怎样填充的?
提示的错误是什么?是编译错误还是运行错误?调用函数的循环代码都有什么?
问题描述怎么这么模糊。
提示的错误是什么?是编译错误还是运行错误?调用函数的循环代码都有什么?
问题描述怎么这么模糊。
#9
函数
function sum1(id:string;k:integer):integer;
如果在Form1单元,请这样改:
function TForm1.sum1(id:string;k:integer):integer;
再按Ctrl+C,产生这个方法的审明部分
function sum1(id:string;k:integer):integer;
如果在Form1单元,请这样改:
function TForm1.sum1(id:string;k:integer):integer;
再按Ctrl+C,产生这个方法的审明部分
#10
回复8楼的,infoID[i]是个string的数组,可以根据i返回id1-id8
错误是编译错误,还不让运行。
错误是编译错误,还不让运行。
#11
回复9楼的,本来这个函数我只用一个参数的,可以正常使用,换成两个参数就不行了,不知道是什么原因,可能调用时格式不对?
#12
y=sum1(infoID[i],k)/10
-------------------->
y:=sum1(infoID[i],k)/10;
就不关函数参数什么事。
-------------------->
y:=sum1(infoID[i],k)/10;
就不关函数参数什么事。
#13
回复12楼的,我在2楼已经说了,的确是漏了个:,但改了还是不行的
#14
y定义的是什么类型?
sum1(...)/10是个extended,能赋给y么?infoID[i]的定义呢?
把代码贴完整好不好?
sum1(...)/10是个extended,能赋给y么?infoID[i]的定义呢?
把代码贴完整好不好?
#15
下面的是代码,运行的时候就提示函数调用那行错误,可能代码比较乱,各位就重点看看函数那部分好了
procedure TForm1.Button15Click(Sender: TObject);
type TArr = array[1..8] of real;
var i:integer;
infoD:real;
infovd:real;
max_gain:string;
temp:real;
gainvd:Tarr;
gainmax:real;
querystring:string;
querystring1:string;
querystring2:string;
const infoID:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const Gain:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const table:array[1..8] of string =('T3111','T3110','T3101','T3100','T3011','T3010','T3001','T3000');
const tablenew:array[1..8] of string =('T4111','T4110','T4101','T4100','T4011','T4010','T4001','T4000');
Function Log(X,Y:double):double;
begin
Try
Result:=Ln(X)/Ln(Y);
except
Result:=0;
end;
end;
function sum1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function sum2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count0(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+'');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function info(i: integer): real;
begin
result:=-(sum1(infoID[i],k)/count0(infoID[i],k)*log(sum1(infoID[i],k)/count0(infoID[i],k),2)-(1-sum1(infoID[i],k)/count0(infoID[i],k))*log((1-sum1(infoID[i],k)/count0(infoID[i],k)),2));
end;
function info2(i: integer): real;
begin
result:=-(sum2(infoID[i],k)/count2(infoID[i],k)*log(sum2(infoID[i],k)/count2(infoID[i],k),2)-(1-sum2(infoID[i],k)/count2(infoID[i],k))*log((1-sum2(infoID[i],k)/count2(infoID[i],k)),2));
end;
begin
for k:=1 to 8 do
begin
infod:=-(sum1('id1',k)/count1('id1',k)*log(sum1('id1',k)/count1('id1',k),2)-(1-sum1('id1',k)/count1('id1',k))*log(1-sum1('id1',k)/count1('id1',k),2));
gainmax:=0;
max_gain:=gain[1];
for i:=2 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
infovd:=info(i)*count0(infoID[i],k)/count1(infoID[i],k)+info2(i)*count2(infoID[i],k)/count1(infoID[i],k);
gainvd[i]:=infod-infovd;
if gainvd[i]>gainmax then
begin
gainmax:=gainvd[i];
max_gain:=gain[i];
b8:=i;
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.add('insert into T (id,gain,infovd,infod) values('+inttostr(i)+','+floattostr(gainvd[i])+','+floattostr(infovd)+','''+max_gain+''')');
execsql;
end;
end;
end;
end;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+1+' ');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+0+' ');
execsql;
end;
for i:=1 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
if max_gain<>gain[i] then
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+1+' add '+gain[i]+' int');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+0+' add '+gain[i]+' int');
execsql;
end;
end;
if gain[i]<>max_gain then
begin
if QueryString <>'' then
begin
QueryString:=QueryString+','+gain[i] ;
end
else
QueryString:=gain[i];
end;
end;
end;
end;
end;
QueryString1:='insert into '+'+tablenew[k]+'+1+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=1';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString1);
execsql;
end;
QueryString2:='insert into '+'+tablenew[k]+'+0+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=0';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString2);
execsql;
end;
end;
end;
end.
procedure TForm1.Button15Click(Sender: TObject);
type TArr = array[1..8] of real;
var i:integer;
infoD:real;
infovd:real;
max_gain:string;
temp:real;
gainvd:Tarr;
gainmax:real;
querystring:string;
querystring1:string;
querystring2:string;
const infoID:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const Gain:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const table:array[1..8] of string =('T3111','T3110','T3101','T3100','T3011','T3010','T3001','T3000');
const tablenew:array[1..8] of string =('T4111','T4110','T4101','T4100','T4011','T4010','T4001','T4000');
Function Log(X,Y:double):double;
begin
Try
Result:=Ln(X)/Ln(Y);
except
Result:=0;
end;
end;
function sum1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function sum2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count0(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+'');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function info(i: integer): real;
begin
result:=-(sum1(infoID[i],k)/count0(infoID[i],k)*log(sum1(infoID[i],k)/count0(infoID[i],k),2)-(1-sum1(infoID[i],k)/count0(infoID[i],k))*log((1-sum1(infoID[i],k)/count0(infoID[i],k)),2));
end;
function info2(i: integer): real;
begin
result:=-(sum2(infoID[i],k)/count2(infoID[i],k)*log(sum2(infoID[i],k)/count2(infoID[i],k),2)-(1-sum2(infoID[i],k)/count2(infoID[i],k))*log((1-sum2(infoID[i],k)/count2(infoID[i],k)),2));
end;
begin
for k:=1 to 8 do
begin
infod:=-(sum1('id1',k)/count1('id1',k)*log(sum1('id1',k)/count1('id1',k),2)-(1-sum1('id1',k)/count1('id1',k))*log(1-sum1('id1',k)/count1('id1',k),2));
gainmax:=0;
max_gain:=gain[1];
for i:=2 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
infovd:=info(i)*count0(infoID[i],k)/count1(infoID[i],k)+info2(i)*count2(infoID[i],k)/count1(infoID[i],k);
gainvd[i]:=infod-infovd;
if gainvd[i]>gainmax then
begin
gainmax:=gainvd[i];
max_gain:=gain[i];
b8:=i;
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.add('insert into T (id,gain,infovd,infod) values('+inttostr(i)+','+floattostr(gainvd[i])+','+floattostr(infovd)+','''+max_gain+''')');
execsql;
end;
end;
end;
end;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+1+' ');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+0+' ');
execsql;
end;
for i:=1 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
if max_gain<>gain[i] then
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+1+' add '+gain[i]+' int');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+0+' add '+gain[i]+' int');
execsql;
end;
end;
if gain[i]<>max_gain then
begin
if QueryString <>'' then
begin
QueryString:=QueryString+','+gain[i] ;
end
else
QueryString:=gain[i];
end;
end;
end;
end;
end;
QueryString1:='insert into '+'+tablenew[k]+'+1+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=1';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString1);
execsql;
end;
QueryString2:='insert into '+'+tablenew[k]+'+0+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=0';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString2);
execsql;
end;
end;
end;
end.
#16
你调用函数的地方,参数k是啥?从哪里来的?编译的时候能通过么?
#17
function sum1(id:string;k:integer):integer; //K 是传进来的参数
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
for k:=1 to 8 do //这里又对K进行循环 上面得参数K换个名
begin
for i:=1 to 8 do
begin
y=sum1(infoID[i],k)/10
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
for k:=1 to 8 do //这里又对K进行循环 上面得参数K换个名
begin
for i:=1 to 8 do
begin
y=sum1(infoID[i],k)/10
#18
格式调整下,难道是我眼神有问题?
#19
o
#20
问题解决了,谢谢16,17楼的大哥
#21
#1
先把这一句y=sum1(infoID[i],k)/10 注释掉试试,看还错不错?
#2
1楼的大哥,你说的什么意思,不太懂,y=sum1(infoID[i],k)/10 这句我漏写了个:,加上也还是不行。
#3
其实问题也就是如何调用具有两个输入参数的函数
#4
单步跟踪,调试一下吧。
#5
4楼的大哥,我想我调用的格式可能不对,但不知道怎么改
#6
你传入的参数类型和Sum1函数的原型说明是否一致?
#7
递归?
#8
infoID[i]是什么,怎样定义的,怎样填充的?
提示的错误是什么?是编译错误还是运行错误?调用函数的循环代码都有什么?
问题描述怎么这么模糊。
提示的错误是什么?是编译错误还是运行错误?调用函数的循环代码都有什么?
问题描述怎么这么模糊。
#9
函数
function sum1(id:string;k:integer):integer;
如果在Form1单元,请这样改:
function TForm1.sum1(id:string;k:integer):integer;
再按Ctrl+C,产生这个方法的审明部分
function sum1(id:string;k:integer):integer;
如果在Form1单元,请这样改:
function TForm1.sum1(id:string;k:integer):integer;
再按Ctrl+C,产生这个方法的审明部分
#10
回复8楼的,infoID[i]是个string的数组,可以根据i返回id1-id8
错误是编译错误,还不让运行。
错误是编译错误,还不让运行。
#11
回复9楼的,本来这个函数我只用一个参数的,可以正常使用,换成两个参数就不行了,不知道是什么原因,可能调用时格式不对?
#12
y=sum1(infoID[i],k)/10
-------------------->
y:=sum1(infoID[i],k)/10;
就不关函数参数什么事。
-------------------->
y:=sum1(infoID[i],k)/10;
就不关函数参数什么事。
#13
回复12楼的,我在2楼已经说了,的确是漏了个:,但改了还是不行的
#14
y定义的是什么类型?
sum1(...)/10是个extended,能赋给y么?infoID[i]的定义呢?
把代码贴完整好不好?
sum1(...)/10是个extended,能赋给y么?infoID[i]的定义呢?
把代码贴完整好不好?
#15
下面的是代码,运行的时候就提示函数调用那行错误,可能代码比较乱,各位就重点看看函数那部分好了
procedure TForm1.Button15Click(Sender: TObject);
type TArr = array[1..8] of real;
var i:integer;
infoD:real;
infovd:real;
max_gain:string;
temp:real;
gainvd:Tarr;
gainmax:real;
querystring:string;
querystring1:string;
querystring2:string;
const infoID:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const Gain:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const table:array[1..8] of string =('T3111','T3110','T3101','T3100','T3011','T3010','T3001','T3000');
const tablenew:array[1..8] of string =('T4111','T4110','T4101','T4100','T4011','T4010','T4001','T4000');
Function Log(X,Y:double):double;
begin
Try
Result:=Ln(X)/Ln(Y);
except
Result:=0;
end;
end;
function sum1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function sum2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count0(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+'');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function info(i: integer): real;
begin
result:=-(sum1(infoID[i],k)/count0(infoID[i],k)*log(sum1(infoID[i],k)/count0(infoID[i],k),2)-(1-sum1(infoID[i],k)/count0(infoID[i],k))*log((1-sum1(infoID[i],k)/count0(infoID[i],k)),2));
end;
function info2(i: integer): real;
begin
result:=-(sum2(infoID[i],k)/count2(infoID[i],k)*log(sum2(infoID[i],k)/count2(infoID[i],k),2)-(1-sum2(infoID[i],k)/count2(infoID[i],k))*log((1-sum2(infoID[i],k)/count2(infoID[i],k)),2));
end;
begin
for k:=1 to 8 do
begin
infod:=-(sum1('id1',k)/count1('id1',k)*log(sum1('id1',k)/count1('id1',k),2)-(1-sum1('id1',k)/count1('id1',k))*log(1-sum1('id1',k)/count1('id1',k),2));
gainmax:=0;
max_gain:=gain[1];
for i:=2 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
infovd:=info(i)*count0(infoID[i],k)/count1(infoID[i],k)+info2(i)*count2(infoID[i],k)/count1(infoID[i],k);
gainvd[i]:=infod-infovd;
if gainvd[i]>gainmax then
begin
gainmax:=gainvd[i];
max_gain:=gain[i];
b8:=i;
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.add('insert into T (id,gain,infovd,infod) values('+inttostr(i)+','+floattostr(gainvd[i])+','+floattostr(infovd)+','''+max_gain+''')');
execsql;
end;
end;
end;
end;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+1+' ');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+0+' ');
execsql;
end;
for i:=1 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
if max_gain<>gain[i] then
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+1+' add '+gain[i]+' int');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+0+' add '+gain[i]+' int');
execsql;
end;
end;
if gain[i]<>max_gain then
begin
if QueryString <>'' then
begin
QueryString:=QueryString+','+gain[i] ;
end
else
QueryString:=gain[i];
end;
end;
end;
end;
end;
QueryString1:='insert into '+'+tablenew[k]+'+1+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=1';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString1);
execsql;
end;
QueryString2:='insert into '+'+tablenew[k]+'+0+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=0';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString2);
execsql;
end;
end;
end;
end.
procedure TForm1.Button15Click(Sender: TObject);
type TArr = array[1..8] of real;
var i:integer;
infoD:real;
infovd:real;
max_gain:string;
temp:real;
gainvd:Tarr;
gainmax:real;
querystring:string;
querystring1:string;
querystring2:string;
const infoID:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const Gain:array[1..8] of string =('id1','id2','id3','id4','id5','id6','id7','id8');
const table:array[1..8] of string =('T3111','T3110','T3101','T3100','T3011','T3010','T3001','T3000');
const tablenew:array[1..8] of string =('T4111','T4110','T4101','T4100','T4011','T4010','T4001','T4000');
Function Log(X,Y:double):double;
begin
Try
Result:=Ln(X)/Ln(Y);
except
Result:=0;
end;
end;
function sum1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function sum2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count0(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count1(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+'');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function count2(id:string;k:integer):integer;
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select count('+id+') from '+table[k]+' where '+id+'=0');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
function info(i: integer): real;
begin
result:=-(sum1(infoID[i],k)/count0(infoID[i],k)*log(sum1(infoID[i],k)/count0(infoID[i],k),2)-(1-sum1(infoID[i],k)/count0(infoID[i],k))*log((1-sum1(infoID[i],k)/count0(infoID[i],k)),2));
end;
function info2(i: integer): real;
begin
result:=-(sum2(infoID[i],k)/count2(infoID[i],k)*log(sum2(infoID[i],k)/count2(infoID[i],k),2)-(1-sum2(infoID[i],k)/count2(infoID[i],k))*log((1-sum2(infoID[i],k)/count2(infoID[i],k)),2));
end;
begin
for k:=1 to 8 do
begin
infod:=-(sum1('id1',k)/count1('id1',k)*log(sum1('id1',k)/count1('id1',k),2)-(1-sum1('id1',k)/count1('id1',k))*log(1-sum1('id1',k)/count1('id1',k),2));
gainmax:=0;
max_gain:=gain[1];
for i:=2 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
infovd:=info(i)*count0(infoID[i],k)/count1(infoID[i],k)+info2(i)*count2(infoID[i],k)/count1(infoID[i],k);
gainvd[i]:=infod-infovd;
if gainvd[i]>gainmax then
begin
gainmax:=gainvd[i];
max_gain:=gain[i];
b8:=i;
end;
with adoquery1 do
begin
close;
sql.Clear;
sql.add('insert into T (id,gain,infovd,infod) values('+inttostr(i)+','+floattostr(gainvd[i])+','+floattostr(infovd)+','''+max_gain+''')');
execsql;
end;
end;
end;
end;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+1+' ');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('create table '+'+tablenew[k]+'+0+' ');
execsql;
end;
for i:=1 to 8 do
begin
if i<>x then
begin
if i<>z then
begin
if i<>a4 then
begin
if max_gain<>gain[i] then
begin
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+1+' add '+gain[i]+' int');
execsql;
end;
with adoquery1 do
begin
close;
sql.clear;
sql.add('alter table '+'+tablenew[k]+'+0+' add '+gain[i]+' int');
execsql;
end;
end;
if gain[i]<>max_gain then
begin
if QueryString <>'' then
begin
QueryString:=QueryString+','+gain[i] ;
end
else
QueryString:=gain[i];
end;
end;
end;
end;
end;
QueryString1:='insert into '+'+tablenew[k]+'+1+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=1';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString1);
execsql;
end;
QueryString2:='insert into '+'+tablenew[k]+'+0+' SELECT '+QueryString+' FROM T3000 where '+max_gain+'=0';
with adoquery1 do
begin
close;
sql.clear;
sql.add(QueryString2);
execsql;
end;
end;
end;
end.
#16
你调用函数的地方,参数k是啥?从哪里来的?编译的时候能通过么?
#17
function sum1(id:string;k:integer):integer; //K 是传进来的参数
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
for k:=1 to 8 do //这里又对K进行循环 上面得参数K换个名
begin
for i:=1 to 8 do
begin
y=sum1(infoID[i],k)/10
begin
with adoquery1 do
begin
close;
sql.Clear;
sql.Add('select sum(id1) from '+table[k]+' where '+id+'=1');
open;
result:=adoquery1.Fields[0].Asinteger;
end;
end;
for k:=1 to 8 do //这里又对K进行循环 上面得参数K换个名
begin
for i:=1 to 8 do
begin
y=sum1(infoID[i],k)/10
#18
格式调整下,难道是我眼神有问题?
#19
o
#20
问题解决了,谢谢16,17楼的大哥