它应该在数据库中吗?看看如何从客户端进程从c#执行。您需要创建表还是只在表中存储数据?更重要的是,你必须在循环中完成吗?你能接受一个不使用循环的SQL答案吗?最后-你能发布你尝试过的SQL吗?我做的SQL就像Pascal代码的失败转换,因为dindt工作了
它应该在数据库中吗?看看如何从客户端进程从c#执行。您需要创建表还是只在表中存储数据?更重要的是,你必须在循环中完成吗?你能接受一个不使用循环的SQL答案吗?最后-你能发布你尝试过的SQL吗?我做的SQL就像Pascal代码的失败转换,因为dindt工作了,c#,visual-studio-2010,sql-server-2008,insert,sqlclr,C#,Visual Studio 2010,Sql Server 2008,Insert,Sqlclr,它应该在数据库中吗?看看如何从客户端进程从c#执行。您需要创建表还是只在表中存储数据?更重要的是,你必须在循环中完成吗?你能接受一个不使用循环的SQL答案吗?最后-你能发布你尝试过的SQL吗?我做的SQL就像Pascal代码的失败转换,因为dindt工作了,我删除了它,但我记得是这样的:@Wisdown-System.OutOfMemoryException可能是因为ManagementStudio无法处理这么多的结果。我们的想法是,您将执行插入到LotteryTable…然后让选择查询将结果插
它应该在数据库中吗?看看如何从客户端进程从c#执行。您需要创建表还是只在表中存储数据?更重要的是,你必须在循环中完成吗?你能接受一个不使用循环的SQL答案吗?最后-你能发布你尝试过的SQL吗?我做的SQL就像Pascal代码的失败转换,因为dindt工作了,我删除了它,但我记得是这样的:@Wisdown-System.OutOfMemoryException可能是因为ManagementStudio无法处理这么多的结果。我们的想法是,您将执行
插入到LotteryTable…
然后让选择
查询将结果插入到表中。我将编辑我的答案以反映这一点。伙计,我喜欢你的例子,我遇到了一个内存问题,比如:执行批处理时出错。错误消息是:Exceção do tipo'System.OutOfMemoryException'foi acionada。但是在出错之前工作得很好,显示了结果。我用更多信息更新了主要问题,谢谢您的帮助。@Wisdown-我已经更新了。在我的旧台式机上运行大约需要11分钟。伙计,我喜欢你的例子,我遇到了一个内存问题,比如:执行批处理时出错。错误消息是:Exceção do tipo'System.OutOfMemoryException'foi acionada。但是在出错之前工作得很好,显示了结果。我用更多信息更新了主要问题,谢谢您的帮助。@Wisdown-我已经更新了。在我的旧台式机上运行大约需要11分钟。
program lotery;
uses fdelay, crt;
var
x,y,z,a,b,c:integer;
cont:longint;
begin
clrscr;
x:=0;
y:=0;
z:=0;
a:=0;
b:=0;
c:=0;
cont:=0;
for x:=0 to 59 do
begin
for y:=x+1 to 59 do
begin
for z:=y+1 to 59 do
begin
for a:=z+1 to 59 do
begin
for b:=a+1 to 59 do
begin
for c:=b+1 to 59 do
begin
cont:=cont+1;
Writeln ('Dezenas: ',x,' - ',y,' - ',z,' - ',a,' - ',b,' - ',c,' = Total de Dezenas: ',cont);
end;
end;
end;
end;
end;
end;
readkey;
end.
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
ofstream myfile;
myfile.open ("Combinacoes.txt");
int total = 0;
for (int contador = 1; contador <= 60; contador++)
for (int Bola_01 = 1; Bola_01 <= 60; Bola_01++)
for (int Bola_02 = 1; Bola_02 <= 60; Bola_02++)
for (int Bola_03 = 1; Bola_03 <= 60; Bola_03++)
for (int Bola_04 = 1; Bola_04 <= 60; Bola_04++)
for (int Bola_05 = 1; Bola_05 <= 60; Bola_05++)
for (int Bola_06 = 1; Bola_06 <= 60; Bola_06++)
{
total = Bola_01 + Bola_02 + Bola_03 + Bola_04 + Bola_05 + Bola_06;
myfile << Bola_01 << "," << Bola_02 << "," << Bola_03 << "," << Bola_04 << "," << Bola_05 << "," << Bola_06 << "," << total << endl;
// printf ("%d , %d , %d , %d , %d , %d , %d \n", Bola_01, Bola_02, Bola_03, Bola_04, Bola_05, Bola_06, total);
total = 0;
}
return 0;
}
/*Table to Hold the Number Combinations*/
CREATE TABLE dbo.LotteryNumbers
(
Number1 INT NOT NULL ,
Number2 INT NOT NULL ,
Number3 INT NOT NULL ,
Number4 INT NOT NULL ,
Number5 INT NOT NULL ,
Number6 INT NOT NULL ,
CONSTRAINT PK_LotteryNumbers PRIMARY KEY CLUSTERED
( Number1, Number2, Number3, Number4, Number5, Number6 )
)
/*Create helper table to hold the ball numbers*/
DECLARE @Balls TABLE ( N INT PRIMARY KEY )
;WITH E00(N) AS (SELECT 1 UNION ALL SELECT 1),
E02(N) AS (SELECT 1 FROM E00 a, E00 b),
E04(N) AS (SELECT 1 FROM E02 a, E02 b),
E08(N) AS (SELECT 1 FROM E04 a, E04 b)
INSERT INTO @Balls( N )
SELECT TOP 59
ROW_NUMBER() OVER ( ORDER BY N )
FROM E08
/*Populate the table of lottery numbers*/
INSERT INTO dbo.LotteryNumbers
SELECT T1.N ,
T2.N ,
T3.N ,
T4.N ,
T5.N ,
T6.N
FROM @Balls T1
JOIN @Balls T2 ON T1.N < T2.N
JOIN @Balls T3 ON T2.N < T3.N
JOIN @Balls T4 ON T3.N < T4.N
JOIN @Balls T5 ON T4.N < T5.N
JOIN @Balls T6 ON T5.N < T6.N