What does For i 1 To 3 mean in algorithm and programming?

Updated on educate 2024-08-06
9 answers
  1. Anonymous users2024-02-15

    Judging from your program, it is going to be executed three times. ":"This is used to separate the values of e and f. If you don't have this program, you will think that e=0f=1, which is wrong and can't be executed. In practice, e and f can also be written in line breaks.

  2. Anonymous users2024-02-14

    The first time i=1, e=0+1=1;f=1+1=2 for the second time, i=2, e=1+2=3, f=2+3=5, third i=3, e=3+5=8, f=5+8=13**********===, note the two debugging outputs.

    e = 0: f = 1

    for i = 1 to 3

    e = e + f

    f = f + e

    NextTracePrint F debug output 13x1 = 0

    y1 = 1

    ax = x1

    ay = y1

    for i = 1 to 3

    ax= x1 + y1

    ay= ax+ay

    NextTracePrint AX Debug Output 1 TracePrint AY Debug Output 4

    traceprint x1 debug output 0

    traceprint y1 debug output 1

  3. Anonymous users2024-02-13

    1. For i=1: x(1)=2,c=6,2>6 is not valid, if execute else,d=d-c,d=0-6=-6

    2. For i=2: x(2)=4,c=6,4>6 is not valid, if else,d=d-c,d=-6-6=-12

    3. For i=3: x(3)=6,c=6,6>6 is not valid, if else,d=d-c,d=-12-6=-18

    4. For i=4: x(4)=8, c=6, 8>6 is established, if executed, d=d+x(4), c=x(4)=8, d=-18+8=-10

    5. For i=5: x(5)=10, c=8, 10>8 is established, if executed, d=d+x(5), c=x(5)=10, d=-10+10=0

    6. For i=6: x(6)=12,c=10,12>10 is established, if executes, d=d+x(6), c=x(6)=12, d=0+12=12

    So in the end d = 12

  4. Anonymous users2024-02-12

    Question 3: DFH, in fact, this problem is to find the value of the second place.

    Question 4: I don't know if you wrote it wrong, or whatever, why did you choose D if you didn't need to count it? Please see the question Xun Li Spine:

    s=s+(-1)*i

    This is always a negative number!

    If nothing else, this should be s=s+(-1) to the i power, right?

    Hahaha.

  5. Anonymous users2024-02-11

    First of all, before the first for loop, arr is a two-dimensional array, 3 rows and 2 columns, and then the for loop is assigned arr(3,2)=3*2+2=8

    redim preserve arr(3,4) means that the original data is not cleared, and the second dimension of the array is expanded, and the original 2 columns become 4 columns, and the data in the first 2 columns is still the data assigned by the first for, and then the for is corrected.

    The two columns of data are assigned arr(3,4)=4+9=13, adding up to 21

  6. Anonymous users2024-02-10

    According to the title, it is necessary to find the sum of the numbers divisible by 3 in a set of numbers arr. Obviously, there are only three numbers, 3, 9, and 15, so the sum is 27

    However, the loop statement in this problem has a syntax error, and when i 10, it is already outside the limit range of the array arr, so we should change for i = 1 to 10 to: for i = 1 to 10

  7. Anonymous users2024-02-09

    Because it is for b=1 to 5 step 2

    So: (5-1) 2+1 = (4) 2+1 = 2+1 = 3 times.

    A: A total of prints were executed"Algorithms & Programming"3 times.

  8. Anonymous users2024-02-08

    This loop, in fact, calculates the result of the loop to the end, because there is no correlation between the results of the previous loop.

    So the final result is: (1 1 2)-2-2=-3

  9. Anonymous users2024-02-07

    The problem is really to find out that the number of these five numbers is greater than 3 (i.e., (1+2+3+4+5) 5=3), which is obviously 4 and 5

Related questions
4 answers2024-08-06

Simple! 1. Define the array a(4,4).

2. In the loop, use int(240+rnd(325-240)) to generate random numbers and assign them to an array, and judge whether it is less than 300, when it is less than 300, add up, and record the number. >>>More

13 answers2024-08-06

dim i as integer

dim s as integer >>>More

6 answers2024-08-06

VB design.

Introduction. What is required. >>>More

17 answers2024-08-06

Not popular, but much easier to learn than other languages.