Questions tagged as 'for'

0
answers

The handle function is not converting - matlab

Hello, I'm getting this error:    Conversion to function_handle from double is not possible. I already looked for the error and tried to change the code but without success. Can you help? A=[99.23;100.05;91;107.71;104.1]; B=[3441 344...
asked by 17.07.2017 / 13:02
4
answers

Sum of cousins in a range in C

My problem is to add cousins to a user-defined range, including ranges if they are prime. Example: ENTRY: 2 and 10 EXIT: 17 I was able to do this: #include <stdio.h> int main() { int numI, numF, primos = 0; scanf("...
asked by 30.06.2018 / 01:25
1
answer

Can I place two conditions / increments within the same loop?

I basically want to do this for (j = parametro, int k=0; j < parametro + 3, k<3; j++, k++) { previsoes[i] += valores[j] * pesos[k] ; }     
asked by 14.11.2017 / 16:34
3
answers

What is the logic behind this function?

Why the result of L1 is: [2, 3, 4] instead of [3, 4]? def remove_dups(L1, L2): for e in L1: if e in L2: L1.remove(e) L1 = [1, 2, 3, 4] L2 = [1, 2, 5, 6] remove_dups(L1, L2) print(L1) I tested it in Python Tut...
asked by 02.04.2018 / 16:53
2
answers

How does a forloop generate random values, then "append" the next set of generated values?

k <- 8 m = 100 for (i in 1:k){ x <- rnorm(mean = i, sd = .5, n=m) y <- rnorm(mean = (8-i), sd = .5, n=m) amostra2 <- data.frame(x,y) } This is the code I have. Given k and m,...
asked by 16.08.2018 / 05:20
2
answers

Remove item from a collection

Why is it incorrect to remove an object from a collection in this way? And why the release of the ConcurrentModificationException exception? for(String item: list) { list.remove(item); }     
asked by 06.11.2018 / 19:36
1
answer

Var within FOR when it starts at 0 (zero) should Count be Count-1?

I picked up a system in the company where I work for another colleague. I note that all FOR's are like this: for(int i = 0; i < lista.count; i++) { //meu código } I learned that when a variable within FOR starts with zero, my COUNT...
asked by 12.03.2015 / 20:03
2
answers

How to get index of an advanced "for"?

I was wondering if I can get some kind of control variable from an "% advanced"%. " For example: On a normal for, I do this as follows: for (int i = 0; i < algumaCoisa.size() ou length; i++){ //código.. } this variable for...
asked by 27.07.2017 / 03:12
2
answers

How to create events in a for loop structure?

My question is the following, I'm developing a program (I'm a beginner) in C #. The part I wanted to improve, is this: I'm wanting to create different events in a for structure. For example: public frmSelecaoDeCartas() { InitializeComponen...
asked by 06.10.2017 / 00:38
1
answer

How to increment a div using For JavaScript

I'm using this code, but it's not catching. I want to increment with each click on the "Increment" button. Code: function incrementar(){ for (let i =0; i<10; i++){ document.getElementById("incrementar2").innerHTML = i; }...
asked by 16.02.2018 / 01:53