✔ 最佳答案
list[10]={0} ==> null vector i.e all elements of vector list are zero
==>
list[0]=0
list[1]=0
.
.
.
list[9]=0
now 1st for loop will run 5 times... i=0 to 4
elements in vector(1D array) "list" with odd index= i+3 (where i=0 to 4)
i.e.
list[1]=0+3=3 where i=0 and 2*i+1=1
list[3]=1+3=4 where i=1 and 2*i+1=3
.
.
a[9]=4+3=7 where i=4 and 2*i+1=9
but elements in vector with even index wont change...that is those values are still zero...
using 2nd for loop you are printing all 10 elements of 1D array
there for output will be
0
3
0
4
0
5
0
6
0
7
EDIT:
@peggy
because in 1st 'for' loop
index=2*i+1 which is always odd for any integer i
so even indexed elements wont change..
@AnalProgrammer
1xn or nx1 matrix is called a vector...
yea you are right I should call it 1D array in programming.