Questions tagged as 'for'

8
answers

Difference between while and for

What is the difference between while and for , if both are loop repeats, if with both I can do the same things either condition a stop or variable iterations because there are both. My question is: Is there a way to demonstrate...
asked by 05.05.2015 / 21:47
2
answers

For with a ";" at the beginning of the loop, which means

I got a code with a for: for (; indField > 0 && indMask > 0; ) What does this ";" mean at the beginning and end of the command?     
asked by 29.12.2016 / 16:17
2
answers

How does the "for" inline command work?

I did a question regarding a Python algorithm, but in resolution of the user Anderson Carlos Woss he used a type of% inline that I had never seen and that left me confused. Here is the code snippet corresponding to for : groups...
asked by 27.09.2017 / 13:54
3
answers

How to calculate perfect numbers quickly?

I'm trying to perform an exercise to show the perfect numbers present within a given range, but I can only do this to the perfect fourth number. If I increase the range, it takes a long time and does not respond: def perfeito(n_max): lista...
asked by 24.09.2018 / 19:56
3
answers

Which loop is faster in C: while or for?

Being a loop while and a for that rotate the same number of times, which is faster? Example: while : int i = 0; int max = 10; while(i<max){ funcao(); i++; } for : int i; int max = 10; for(i=0; i<...
asked by 10.12.2015 / 19:00
4
answers

What would be a good way to apply events: onMouseOver and onMouseOut, for all img tag?

I need this function to be automated so that it applies to all images made on the HTML document without any exception Code function aumenta(obj) { obj.height = obj.height * 2; obj.width = obj.width * 2; } function diminui(...
asked by 08.02.2017 / 18:28
2
answers

C ++ (basic): for, references and syntax

My teacher introduced this role to us: void escala(std::vector<double> &v, double fator) { for (auto &vi:v){ vi *= fator; } } It serves to multiply all elements of a vector by an already predefined factor. I h...
asked by 07.05.2018 / 13:20
2
answers

Why is this loop "for" not infinite?

public class Loop { public static void main(String[] a) { int cont=0; for (int i=0; i>=0; i+=2, cont++); System.out.println("cont:"+cont); }} I was struck by the condition of the loop for i>=0 . At the time I thought: loop infini...
asked by 31.08.2018 / 21:04
2
answers

Which loop is faster for or foreach in C #?

I've read articles from some programming languages that the for loop is faster than the foreach , and was wondering if C # has performance differences? >     
asked by 12.10.2016 / 23:21
2
answers

What's the difference between For, ForEach and Find in JavaScript?

What's the difference between the 3? For , ForEach , and Find     
asked by 24.01.2018 / 17:24