|
-
February 17th, 2012, 03:37 PM
#8
Re: shifting a 32bit in a array!!!!
 Originally Posted by S_M_A
Frankly, why is it so impossible to spend a few minutes to write a question that clearly states the issue?
Assuming that you want to shift
int p[32]={1,0,1,1,0,1,0,1,0,0,1,0,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,1,0,1,1,0} from left to right this should do it
Code:
for(int i=1;i<31;i++)
{
p[i]=p[i-1];
}
p[31] = 0;
Not perhaps rather something like:
Code:
for(int i = 31; i > 0; i--)
{
p[i]=p[i-1];
}
p[0] = 0;
? 
Based on the assumption, of course, that "left" means the end with the lower index, i.e. 0, just like it's written in the initializer.
Now I just hope you didn't just want to give the OP something to debug and now I've spoiled it...
I was thrown out of college for cheating on the metaphysics exam; I looked into the soul of the boy sitting next to me.
This is a snakeskin jacket! And for me it's a symbol of my individuality, and my belief... in personal freedom.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|