C language array applet problem. C language array problem.

Updated on technology 2024-04-01
7 answers
  1. Anonymous users2024-02-07

    In the whole main function, only this one variable, whether it is the first for or the second for, is the same i, the second for will have i=-1, in the case of i= -1, and printf("%d ",a[i]);Statement. So fear not! When there is no second for the case:

    After the first for is executed, i has become 10, but the size of your array is 10, if i is 10, it points to the 11th position of your array, your subscript is out of bounds, and the consequences of crossing the line will cause your program to crash, but now there is no crash, the output must be garbled code, -36 is just a superficial phenomenon, in fact, a[10] is an indefinite number, it may be -36, or it may be other numbers. Summary:1

    To check subscripts, subscripts that go out of bounds is a common mistake made by programmers, resulting in system crashes, memory leaks, and sometimes looking for a long time without finding the problem. 2. In the for statement, even if there is only one statement, add {} to develop good programming habits!

  2. Anonymous users2024-02-06

    The output must be the value of a[i] in the second for will not appear i = -1, your i > = 0 has been given a limit is not -36, if there is no second for, the output value must be 9, do you check whether other places have done other operations for a[i]?

  3. Anonymous users2024-02-05

    It's the ia in the second for, and the second for will have i = -1, but it's only executed in the background program The output is only stopped until a[0], and the third case is not clear.

  4. Anonymous users2024-02-04

    The first dimension of a two-dimensional array can be omitted, but the second dimension cannot be omitted, and the value of the first dimension can be obtained by assigning the value of the second dimension and the array.

    In this problem, there are 10 array elements, 10 5=2

    Thus, it can be seen that the first dimension is 2 choices b

  5. Anonymous users2024-02-03

    Select B 2

    9 elements are defined, and the size of the second dimension is 5, so the size of the first dimension is 2

  6. Anonymous users2024-02-02

    The initial value of array c is 0.

    The array s is then recycled to compute the value of array c.

    i=0, c[s[0]]+c[1]++0++i=1, c[s[1]]+c[2]++0++i=2, c[s[2]]+c[3]++0++ and so on, the array c[1] is ++ 4 times, c[2] is performed 3 times, c[3] is performed 3 times, c[4] is performed 2 times.

  7. Anonymous users2024-02-01

    Answer: B

    This is the count sorting.

    The sentence c[s[i]]+ is the number of s[i] counts.

    Specifically, for example, if s[i]=1;

    c[s[i]]=c[1], then the following is ,..s[i]=4; c[s[i]]=c[4];

    c[s[i]]+ is the number of s[i] counted.

    for(int i=1; i<5;i++) outputs the number of 1, 2, 3, and 4 in turn.

    printf("%d ", c[i]);

    It is the number of numbers corresponding to the output s[i].

Related questions
8 answers2024-04-01

2D array address - > row address - > column address (variable address) - > variable value, or excerpt a description for you. >>>More

16 answers2024-04-01

Array of pointers. First of all, it is an array, the elements of the array are all pointers, and the number of bytes occupied by the array is determined by the array itself. It is short for "array of stored pointers". >>>More

10 answers2024-04-01

Here's a C implementation that assigns an array a[10] to p[n]: >>>More

12 answers2024-04-01

One-dimensional arrays hold the same values, but in the case of matrices, determinants. >>>More