Questions tagged as 'loop'

3
answers

Faster way to access properties in a list C #

I have a project that works with a large volume of data, and I need to optimize it to bring results of some calculations in a considerably small time. I know I have several aspects to take into consideration, such as the structure in which the d...
asked by 30.03.2016 / 15:15
2
answers

Why this code goes into infinite loop?

Why do I put an invalid entry as asdf the code below goes into infinite loop? After catching the exception and writing the message, should not it ask for another entry again? import java.util.Scanner; public class Leitura { public st...
asked by 04.04.2014 / 05:22
2
answers

Is there any difference between an infinite loop with for and while?

In PHP, you can generate an infinite loop with while simply by passing the true parameter. Example: while (true) { echo "Ao infinito e além"; } It is also possible to generate this through for , simply omittin...
asked by 01.10.2015 / 22:55
1
answer

Brute force algorithm for game resolution Sudoku in C

I have the following code written in C : #include <stdio.h> #include <stdlib.h> #include <time.h> // Variáveis globais int jogo_tabuleiro[9][9] = {0}; int func_quadrante(int quadrante, int numero) { int linha_inic...
asked by 28.06.2016 / 06:00
6
answers

How to change the background of rows in a table alternately? Supported by browsers

My table is created with a loop in PHP. Do I do this by PHP even adding a condition or has it any better? if ($nomSenha == 'xxxxxxxx') { echo '<table class="pesquisaClientes">'; echo '<tr>'; echo '<td class="id">Id</td...
asked by 12.12.2013 / 12:41
5
answers

Use if inside foreach

I am trying to change the order in which the results appear within a loop using foreach. What I need is for numbers greater than five to appear first, followed by the rest of the numbers. So I tried something like this: $numeros = array(1, 2,...
asked by 09.05.2014 / 19:47
3
answers

INSERT Query does not work inside a loop

So folks, I'm not able to solve this problem of a query inside a foreach loop does not execute. First of all I thought it was something wrong with pdo-> beginTransaction so I commented this part and left pure code only. <?php if (is...
asked by 10.08.2014 / 01:31
2
answers

How to insert a header to each N records?

How can I insert a header to each N records? Like ... <h1>CABECALHO</h1> Cadastro 1 Cadastro 2 Cadastro 3 Cadastro N <h1>CABECALHO</h1> Cadastro .. Cadastro .. Cadastro .. Cadastr...
asked by 06.10.2014 / 05:51
2
answers

Why are loops slow in R? How to avoid them?

It is very common to hear (or read) that loops are not efficient in R and should be avoided ( in this link or on another link or same in this ). And proving this statement is simple: numeros <- rnorm(10000) com_loop <- fun...
asked by 26.10.2017 / 14:51
2
answers

How to create a for in R with the indexes of a data frame

If I have a data.frame: > dato<-as.data.frame(matrix(1:64,8,8,T))[-3,] > dato V1 V2 V3 V4 V5 V6 V7 V8 1 1 2 3 4 5 6 7 8 2 9 10 11 12 13 14 15 16 4 25 26 27 28 29 30 31 32 5 33 34 35 36 37 38 39 40 6 41 42 43 44 45 46 47 48...
asked by 01.05.2018 / 16:15