排列组合算法程序用C.C++.asp.或者jsp.vb.随便一种语言.输出1到33.33个数.从中选6个数.不重复.输出
来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/15 03:30:15
排列组合算法程序
用C.C++.asp.或者jsp.vb.随便一种语言.输出
1到33.33个数.从中选6个数.不重复.输出所有可能排列.不分顺序.
写出完成算法程序.附带注释.
用C.C++.asp.或者jsp.vb.随便一种语言.输出
1到33.33个数.从中选6个数.不重复.输出所有可能排列.不分顺序.
写出完成算法程序.附带注释.
unit Unit2;
interface
uses
Classes,ADODB,SysUtils,DB,ActiveX ;
type
AllNumber = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
procedure ADOADDEdit(ado:TADOQuery;str:String);
end;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure AllNumber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ AllNumber }
procedure AllNumber.ADOADDEdit(ado: TADOQuery; str: String);
begin
ado.Close ;
ado.SQL.Clear ;
ado.SQL.Add(str) ;
ado.ExecSQL ;
end;
procedure AllNumber.Execute;
var
ado:TADOQuery;
a,b,c,d,e,f,g,sum:Integer;
str:string;
begin
CoInitialize(nil);
ado := TADOQuery.Create(nil);
ado.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBase\data.mdb;Persist Security Info=False';
FreeOnTerminate := true;
for a := 1 to 30 do
for b:= a+1 to 31 do
for c := b+1 to 32 do
for d := c+1 to 33 do
for e := d+1 to 34 do
for f := e+1 to 35 do
for g := f+1 to 36 do
begin
if (a b) and (a c) and (a d) and (ae) and (af) and (ag) and (bc) and (bd) and (be) and (bf) and (bg) and (cd) and (ce) and (cf) and (cg) and (de) and (df) and (dg) and (ef) and (eg) and (fg) then
begin
sum := a+b+c+d+e+f+g;
str := 'insert into numnumshu (one,two,three,four,five,six,seven,NumSum) Values('''+IntToStr(a)+''','''+IntToStr(b)+''','''+IntToStr(c)+''','''+IntToStr(d)+''','''+IntToStr(e)+''','''+IntToStr(f)+''','''+IntToStr(g)+''','''+IntToStr(sum)+''')';
ADOADDEdit(ado,str);
end;
end;
FreeAndNil(ado);
CoUninitialize();
end;
end.
这个是我自己写的一个线程,用来产生所有不同的号码,不过我算得是36选七,你把它改成33选六就可以了
interface
uses
Classes,ADODB,SysUtils,DB,ActiveX ;
type
AllNumber = class(TThread)
private
{ Private declarations }
protected
procedure Execute; override;
procedure ADOADDEdit(ado:TADOQuery;str:String);
end;
implementation
{ Important: Methods and properties of objects in visual components can only be
used in a method called using Synchronize, for example,
Synchronize(UpdateCaption);
and UpdateCaption could look like,
procedure AllNumber.UpdateCaption;
begin
Form1.Caption := 'Updated in a thread';
end; }
{ AllNumber }
procedure AllNumber.ADOADDEdit(ado: TADOQuery; str: String);
begin
ado.Close ;
ado.SQL.Clear ;
ado.SQL.Add(str) ;
ado.ExecSQL ;
end;
procedure AllNumber.Execute;
var
ado:TADOQuery;
a,b,c,d,e,f,g,sum:Integer;
str:string;
begin
CoInitialize(nil);
ado := TADOQuery.Create(nil);
ado.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=DataBase\data.mdb;Persist Security Info=False';
FreeOnTerminate := true;
for a := 1 to 30 do
for b:= a+1 to 31 do
for c := b+1 to 32 do
for d := c+1 to 33 do
for e := d+1 to 34 do
for f := e+1 to 35 do
for g := f+1 to 36 do
begin
if (a b) and (a c) and (a d) and (ae) and (af) and (ag) and (bc) and (bd) and (be) and (bf) and (bg) and (cd) and (ce) and (cf) and (cg) and (de) and (df) and (dg) and (ef) and (eg) and (fg) then
begin
sum := a+b+c+d+e+f+g;
str := 'insert into numnumshu (one,two,three,four,five,six,seven,NumSum) Values('''+IntToStr(a)+''','''+IntToStr(b)+''','''+IntToStr(c)+''','''+IntToStr(d)+''','''+IntToStr(e)+''','''+IntToStr(f)+''','''+IntToStr(g)+''','''+IntToStr(sum)+''')';
ADOADDEdit(ado,str);
end;
end;
FreeAndNil(ado);
CoUninitialize();
end;
end.
这个是我自己写的一个线程,用来产生所有不同的号码,不过我算得是36选七,你把它改成33选六就可以了
排列组合算法程序用C.C++.asp.或者jsp.vb.随便一种语言.输出1到33.33个数.从中选6个数.不重复.输出
设计C语言程序:1、3、5、7四个数字组成的互不相同且无重复数字的三位数?分别是几?要求每行输出6个数
用C语言写一程序,要求输入10个数,输出这10个数中最大的那个数,同时输出这10个数的平均值
从键盘上输入10个数,C语言程序:用起泡法对这10个数排从小到大的顺序排序后输出.
伪代码算法 c语言 1.从键盘输入10个数,输出其中的最大数2.从键盘输入3个数,要求按大小顺序输出三个数3.求1+3+
c语言计算1+2+3...到20,每加1个数输出一次结果
C语言中如何输出1到100的奇数个数
C语言问题:要求屏幕输出1到100之间奇数的个数.
c语言程序! 1到100的自然数中,每次取出2个数,使他们的和大于100.要求输入较小的一个输出所有取值
C语言一道算法题设计一个程序,对应于正整数输出其所有素因子(多重因子重复输出);对于负数,首先输出-1,然后输出所有因子
c语言程序:从键盘任意输入10个数,要求找出里面最大的数和最小的数,并输出这10个数.
编一个C语言程序从1加到100并输出结果