设有n个整数,现在要使前面各数顺序向后移m个位置,最后m个数变成最前面m个数。

方法一:先将最后m个数保存在新的b数组中,然后将n-m个数拉至原数组a尾部,再将b数组依次赋值给a数组的前m个数。 #include<stdio.h> #define N 80 int main(){ int a[N],b[N],i; int n,m; printf("input the n and m:\n"); scanf("%d %d",&n,&m); for(i=0;
相关文章
相关标签/搜索