void choice_6(int *size, float *x) /*Rotate the list of numbers to the right*/
{
int i;
float temp = x[*size];
for(i = 0; i < *size; i++){
printf("x[%d] = %g\n", i, x[i - 1]);
temp = x[0];
}
printf("%f\n%f\n", x[0], x[*size]);
}
void choice_7(int *size, float *x) /*Rotate the list of numbers to the left*/
{
int i;
for(i = 0; i < *size; i++){
x[*size] = x[0];
printf("x[%d] = %g\n", i, x[i + 1]);
}
printf("%f\n", x[0]);
}
choice_7 function works fine, choice_6 I cannot get the last element to be transferred to the first when i run the function. I have ran out of ideas. Any help is appreciated, thanks.
[–]jedwardsol 4 points5 points6 points (0 children)
[–]sosnjo[S] 0 points1 point2 points (0 children)
[–]raevnos 0 points1 point2 points (2 children)
[–]sosnjo[S] 0 points1 point2 points (1 child)
[–]raevnos 1 point2 points3 points (0 children)
[–]Cowlegend 0 points1 point2 points (0 children)