weird output when i was filling an array HELP

when i do this
1
2
3
4
5
for (int i =M+1;i<=E;i++) //filling up the left Side
   {
      L[K++]=int(A[i]);
      cout<<L[K]<<endl;
   }


i get this in which 4199570 is a wierd number which is not in the input to begin with
1
2
3
4
5
6
7
8
9
10
11
12
16
16
5
4199570
16
16
6
0
5
6
9
32



when i do this *which should be no difference from the first code

1
2
3
4
5
for (int i =M+1;i<=E;i++) //filling up the left Side
   {
      L[K++]=int(A[i]);
      cout<<L[K]<<" "<<K<<endl;
   }


it outputs this
1
2
3
4
5
6
7
8
9
10
11
12
4199570 1
4199570 1
5 1
3 2
1877994272 1
1877994272 1
6 1
2686440 2
5 1
6 2
9 3
16 4
Not enough information.

Though, I think it's because you give a value to L[K], then you print out the next element in the range (L[K + 1]), which has no value yet (undefined).
Last edited on
thanx ^^
Topic archived. No new replies allowed.