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:
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;
}