public bool SimularSorteios(decimal qtd_sorteios) { StructResultados Str_tmp = new StructResultados(); Str_tmp.Dezenas = new List <int>(); int dezena = 0; bool achou = true; Random rnd = new Random(DateTime.Now.Millisecond); try { for (int i = 0; i < qtd_sorteios; i++) { for (int j = 0; j < MainWindow.dezenas_sorteadas; j++) { achou = false; dezena = rnd.Next(MainWindow.dezena_inicial, MainWindow.dezena_final + 1); for (int k = 0; k < Str_tmp.Dezenas.Count; k++) { if (Str_tmp.Dezenas[k] == dezena) { achou = true; break; } else { achou = false; } } while (achou) { dezena = rnd.Next(MainWindow.dezena_inicial, MainWindow.dezena_final + 1); for (int k = 0; k < Str_tmp.Dezenas.Count; k++) { if (Str_tmp.Dezenas[k] == dezena) { achou = true; break; } else { achou = false; } } } Str_tmp.Dezenas.Add(dezena); } Str_tmp.Sorteio = MainWindow.Resultados[MainWindow.Resultados.Count - 1].Sorteio + 1; Str_tmp.Dezenas.Sort(); MainWindow.Resultados.Add(Str_tmp); Str_tmp = new StructResultados(); Str_tmp.Dezenas = new List <int>(); } return(true); } catch { return(false); } }
public bool GeraCombinacoes(out List <StructResultados> Matriz, int[] VDezenas, int s) { Matriz = new List <StructResultados>(); StructResultados StrTmp = new StructResultados(); StrTmp.Dezenas = new List <int>(s); int i = 0, j = 0; int n = VDezenas.Length; int[] VCombIndex = new int[s]; int len = (int)AnaliseCombinatoria.numCombin(VDezenas.Length, s); if (len >= 252) { if (System.Windows.Forms.MessageBox.Show("Encontradas " + len.ToString() + " Combinações! Continuar com Processamento?", "TearDown - Imprimir " + MainWindow.NomeLoteria, System.Windows.Forms.MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return(false); } } // Primeira Combinação for (i = 0; i < s; ++i) { VCombIndex[i] = i; } // Pega as Dezenas em VDezenas de acordo com os indices da primeira combinação for (j = 0; j < VCombIndex.Length; j++) { StrTmp.Dezenas.Add(VDezenas[VCombIndex[j]]); } Matriz.Add(StrTmp); int ret = 1; // Pega as outras dezenas em VDezenas de acordo com os indices das outras combinações while (ret != 0) { ret = ProxCombinacao(VCombIndex, s, n); if (ret == 0) { break; } StrTmp = new StructResultados(); StrTmp.Dezenas = new List <int>(s); for (j = 0; j < VCombIndex.Length; j++) { StrTmp.Dezenas.Add(VDezenas[VCombIndex[j]]); } Matriz.Add(StrTmp); } return(true); }
public bool ResultExtractor(String filename, int range) { bool grava = false; int jog_ind = 1, dic_ind = 1; bool name_ok = false; var web = new HtmlWeb(); var doc = web.Load(filename); string[] nome; StructResultados StructJogos = null; try { // Verifica o nome da Loteria var nodes = doc.DocumentNode.SelectNodes("//title"); foreach (var node in nodes) { nome = Regex.Split(node.InnerText, " "); for (int i = 0; i < nome.Length; i++) { if (Regex.IsMatch(nome[i], "Lotofácil") || Regex.IsMatch(nome[i], "Lotomania") || Regex.IsMatch(nome[i], "Mega-sena")) { MainWindow.NomeLoteria = nome[i]; name_ok = true; break; } } } if (name_ok) { nodes = doc.DocumentNode.SelectNodes("//td"); MainWindow.Resultados.Clear(); if (nodes != null) { foreach (var node in nodes) { if (node == null) { continue; } if (Regex.IsMatch(node.InnerText, "([0-9][0-9])/([0-9][0-9])/([0-9][0-9])([0-9][0-9])")) { grava = true; StructJogos = new StructResultados(); StructJogos.Dezenas = new List <int>(); continue; } if (grava) { StructJogos.Dezenas.Add(Convert.ToInt32(node.InnerText)); jog_ind++; if (jog_ind > range) { StructJogos.Sorteio = dic_ind; StructJogos.flag = false; StructJogos.Dezenas.Sort(); MainWindow.Resultados.Add(StructJogos); grava = false; jog_ind = 1; dic_ind++; } } } } } else { MessageBox.Show("Arquivo Inválido."); return(false); } } catch { return(false); } return(true); }