void fun(int a[], int n, int m)
{
int s[m];
for (int i = 0; i < m; ++i)
{
s[i] = a[i];
}
for (int i = 0; i < n - m; ++i)
{
a[i] = a[i + m];
}
for (int i = n - m; i < n; ++i)
{
a[i] = s[i + m - n];
}
}
就是memmove
#include <stdio.h>
#include <string.h>
int main()
{ int i, a[6]={1,2,3,4,5,6}, b[6]; memmove(b, a+4, 2*sizeof(int)); memmove(b+2, a, 4*sizeof(int)); for (i=0; i<6; i++) printf("%d",b[i]);
}