0

I have doubt in the following code..the value of p and j is not getting incremented after each iteration.what should I do?

for(int y=0;y<2;y++)         {             int p=0,j=4, l=8,mid=8;             for(int i=p;i<j;i++)             {                 if(mid==1)                     mid=1;                 else                     mid=mid/2;                 if(a[i]=='0')                     l=l-mid; //8-4,4-2,2-1                 else                     l=l+mid;             }             if(l>=1)                 l--;             cout<<ar[l];             p=p+4;             j=j+4;         }              

5th Jan 2021, 2:43 PM
Aman Rana
Aman Rana - avatar
4 Respostas
+ 5
aman rana What is your array elements how many elements it has..?? https://code.sololearn.com/c74p8UVgYi5j/?ref=app
5th Jan 2021, 3:46 PM
NavyaSri
NavyaSri - avatar
+ 4
aman rana what is the z value..? show your full attempt . then will help you. (or) { \\maintain curly brases to if and else statements for code readability }
5th Jan 2021, 2:58 PM
NavyaSri
NavyaSri - avatar
0
Wait I will put it again
5th Jan 2021, 3:15 PM
Aman Rana
Aman Rana - avatar
0
Now see
5th Jan 2021, 3:16 PM
Aman Rana
Aman Rana - avatar