Shifting Numbers Inside Array

Joined
Nov 20, 2009
Messages
1
Reaction score
0
Hello there,
I am trying to do a program that shifts the nubmers in array by 1 to the right. For example we have an array with numbers [1,2,3,4] and the output should be [4,1,2,3], but apperantly I am missing stuff and I cannot find any answers ;( i looked through many websites and books but I cant find anything. Could u help me ?
Here's my work so far:

Code:
#include <iostream>
#include <stdlib.h>


using namespace std;
void ShiftRight (int myArray[], int m)
{
     int i=0;
     for (i=m-1;i<m;i--)
         {
                        myArray[i+m]=myArray[i];
         }
}
int main()
{
     int i = 0;
     int myOutput;
     int myArray[i];
     int m;
     
     cout << "Please specify how many numbers will your array have: ";
     cin >> i;
     
    while ( i > 0 )
    {
          for (int m = 0; m < i; m = i - 1 ) 
          {
              myOutput = myArray[m] << 1;
          }
    }
     
     ShiftRight(myArray[m],myOutput);
     system ("pause");
     return 0;
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top