#define ARRSIZE 10
struct Array
{
int data[ARRSIZE];
int curpose;
int maxsize;
};
void Init_Ar(struct Array* x)
{
assert(x != nullptr);
int ar[ARRSIZE] = { 12,23,34,45,56,67,78,89,90,100 };
x->curpose = 0;
x->maxsize = ARRSIZE;
for (int i = 0; i < x->maxsize; ++i)
{
x->data[i] = ar[i];
}
}
void Get_ar(struct Array* x, int index)
{
for (int i = 0; i < x->maxsize; ++i)
{
printf("%d ", x->data[(i + index) % 10]);
}
}
int main()
{
Array x;
Init_Ar(&x);
printf("数组原顺序:\n");
Get_ar(&x, 0);
printf("\n");
printf("请输入数组移动的位数:\n");
scanf_s("%d", &x.curpose);
printf("数组现顺序:\n");
Get_ar(&x, x.curpose);
return 0;
}
05-08
531
09-28
854