5,392
社区成员
发帖
与我相关
我的任务
分享
temp := random(i - 1) + 1;
r := thao[temp];
q := random(9) + 1;
ran := r * 10 + q;
while choosenumber <> 0 do
begin
query1.Close;
query1.SQL.Clear;
query1.SQL.Add('select tno from ti_choose'); // 查询所有题号
if ListBox2.Count >= 1 then // 估计题号添加到了LBX
begin
for mm := 1 to 9 do
begin
if TF[mm] = 't' then
begin
// 此时sql--> select tno from ti_choose where tno not like '1%'
// 添加数据过滤条件 1
query1.SQL.Add(' where tno not like ''' + inttostr(mm) + '%''');
break;
end;
end;
if ListBox2.Count > 1 then
begin
for mm := 1 to 9 do
if TF[mm] = 't' then
begin
// 此时sql--> select tno from ti_choose where tno not like '1%' and and tno not like '2%'
// 添加数据过滤条件 2
query1.SQL.Add(' and tno not like ''' + inttostr(mm) + '%''');
end;
end;
end;
query1.Open; // 执行sql查询数据
query1.First; // RecNo第一条数据
while not query1.Eof do // 遍历数据集
begin
hade := false;
if i = 1 then
begin
thao[i] := ((query1.FieldValues['tno']) div 10); // 第一题? 存入题号
end
else if i > 1 then
begin
for j := i - 1 downto 1 do
begin
if thao[j] = ((query1.FieldValues['tno']) div 10) then
begin
t := true;
break;
end
else
t := false;
end;
if not t then
begin
thao[i] := ((query1.FieldValues['tno']) div 10);
t := false;
end;
end;
query1.Next;
if not t then
i := i + 1;
end;
// 选题(一种算法不懂)
temp := random(i - 1) + 1;
r := thao[temp];
q := random(9) + 1;
ran := r * 10 + q;
for m := 1 to 800 do
havetake[m] := 0;
for m := 1 to 800 do
begin
if havetake[m] = ran then
begin
showmessage('chongfu');
hade := true;
break;
end;
end;
if not hade then
begin
for m := 0 to 800 do
if havetake[m] = 0 then
begin
havetake[m] := ran;
break;
end;
query1.Close;
query1.SQL.Clear;
query1.SQL.Add(
'select tigan,xa,xb,xc,xd,answer,difficulty from ti_choose where tno=:no'
);
query1.ParamByName('no').Value := ran;
query1.Open;
if choosenumber <> 0 then
begin
if query1.RecordCount <> 0 then
begin
n := strtoint(query1.FieldByName('difficulty').AsString);
if diff[n] <> 0 then
begin
tt := tt + 1;
memo1.Text := memo1.Text + inttostr(tt) + '、 ' + query1.FieldByName
('tigan').AsString + #13#10;
memo1.Text := memo1.Text + query1.FieldByName('xa').AsString + #13#10;
memo1.Text := memo1.Text + query1.FieldByName('xb').AsString + #13#10;
memo1.Text := memo1.Text + query1.FieldByName('xc').AsString + #13#10;
memo1.Text := memo1.Text + query1.FieldByName('xd').AsString + #13#10;
autoanswerform.memo1.Text := autoanswerform.memo1.Text + inttostr(tt)
+ '、 ' + query1.FieldByName('answer').AsString + #13#10;
choosenumber := choosenumber - 1;
n := n - 1;
end;
end;
end;
end;
end;