Scenario one, the display of the shift, the actual non-shift occurs.
#include <stdio.h>
#include <math.h>
void Main () {
int a[10],i,*p,n;
n=4;
Srand (Time ());
printf ("array:");
for (i=0;i<10;i++) {
A[i]=rand ()%100;
printf ("%-4d", A[i]);
}
printf ("\ n");
p=&a[n];
printf ("Now the Vegetarian Group");
for (i=n;i<10;i++) {
printf ("%-4d", *p++);
}
for (i=0;i<n;i++) {
printf ("%-4d", A[i]);
}
printf ("\ n");
}
Scenario two, the display and the actual shift occurs.
#include <stdio.h>
void Move (int *pa,int n,int m) {
int *p,*q;
int i,temp;
for (p=pa+n-m;p<pa+n;p++) {
temp=*p;
for (q=p-1;q>=p-(n-m); q--)
* (q+1) =*q;
* (q+1) =temp;
}
}
Main () {
int number[10],m,i;
printf ("Back M:");
scanf ("%d", &m);
printf ("Input array elements.\n");
for (i=0;i<10;i++)
scanf ("%d", &number[i]);
move (number,10,m);
for (i=0;i<10;i++)
printf ("%d", Number[i]);
printf ("\ n");
}
The C language pointer implements the shift of the array element