VB questions, this kind of questions will not be encountered every time, I hope to explain in as muc

Updated on healthy 2024-05-12
5 answers
  1. Anonymous users2024-02-10

    You have two calls to sun1 here, static i as integer is the first one.

    II. The third ......When the sub procedure is called, the i value does not change to the initial value of 0 and continues to run.

    First, call(x,x,z),x is passed to a,a=1, in the same way b=1,c=3,i=1+3+0=4,a=3*3+4=13,b=10,c=24. Because call(x,x,z), a=b, i.e. there is an implicit execution statement a=b=10, so the last first line prints 10 10 24.

    After call(x,y,y), because it is passed by address, x=10, y=2, i.e. a=10, b=2, c=2. Because static, i is still equal to 4 and the initial value 0 is not assigned, i = 10 + 2 + 4 = 16, a = 22, b = 20, c = 58 (similarly, implicit b = c = 58), so the last second line prints 22 58 58. Because of the value passing, x=22, y=58, z=24, that is, the third line prints 22 58 24

  2. Anonymous users2024-02-09

    Emphasis is placed on static variables. (Static variables, the value of the variable will not be cleared after the process is executed, and the value of the last saved variable will not be re-initialized to 0 when the next call is made).

    After remembering this, you need to record the value of the static variable separately when doing this problem, and update it once when you execute a line.

    As my title:

    The first time sun1(1,1,3) is executed, i=0, and i=a+c+i=1+3+0=4 is executed, and i=4 is recorded on paper

    The second time sun1(1,2,2) is executed, i=4, and i=a+c+i=1+2+4=7 is executed, i=7 is recorded on paper

  3. Anonymous users2024-02-08

    The first time sun1(x,x,z) is called, x=1; x=1;z=3 brings a, b, c, i.e. a=1; b=1;c=3;

    Function starts calculation:

    static i initialization, i=0;

    i=a+c+i=1+3+0=4;

    a=3*c+i=3*3+4=13;Return to the argument x, i.e., x=13;sun1(13,x,z)

    b=2*c+i=2*3+4=10;Return to the argument x, i.e., x=10;sun1(10,10,z) ps: Since x uses the same address to store the value, the value of y should be the same, here the value of x is assigned to 10, so the two x parameters become 10

    c=a+b+i=10+10+4=24;Return to the argument x, i.e., z=24;sun1(10,10,24)

    print outputs a, b, and c are outputs"10 10 24";

    the second call sun1(x,y,y), x=10; y=2;y=2 brings a, b, c, i.e. a=10, b=2, c=2

    Since static i is a static variable, the system allocates a memory storage address for i, which stores the value assigned to i by the last call sun1(), that is, i=4;

    Function starts calculation:

    i=a+c+i=10+2+4=16;

    a=3*c+i=3*2+16=22;Return to the argument x, i.e., x=22;sun1(22,y,y)

    b=2*c+i=2*2+16=20;Return to the real argument y, i.e., y=20;sun1(22,20,y)

    c=a+b+i=22+20+16=58;Return to the real argument y, i.e., y=58;sun1(22,58,58) ps: Since y uses the value stored in the same address, the value of y should be the same, and the value of y is assigned to 58, so the two y parameters become 58

    print outputs a, b, and c are outputs"22 58 58";

  4. Anonymous users2024-02-07

    This kind of topic is not explained to solve the problem, but you need to start from scratch and study hard!

    The explanations of so many friends are nothing more than the contents of the book!

  5. Anonymous users2024-02-06

    Take a look at the basic books of VB and you will understand, simple explanations are useless.

Related questions
12 answers2024-05-12

Someone replies once, and they will be on the first place again!

21 answers2024-05-12

Maggie Cheung's "mortal enemy" in life is Zhang Ziyi. >>>More

14 answers2024-05-12

As the number of cars increases, road conditions become more complex. It's easy to hit someone else's car by mistake, and sometimes it's hard to tell. Especially for some people who specialize in porcelain, things will become more complicated. >>>More

11 answers2024-05-12

In fact, luck is also a kind of strength. It's his luck that he can be lazy and know nothing, but it's his luck to get a job, but if he doesn't have anything to do when he actually works, and he's also very lazy and unwilling to learn, it's actually very dangerous. <>

3 answers2024-05-12

This test is not very important and should not be taken to heart. >>>More