标签:src code scanf 数组 开始 tor images iar 存储
#include<stdio.h>
int arr[101];
void Priarr(int a,int b){
if(a<=b)
for(int i=a;i<=b;i++){
if(i!=a)printf(" ");
printf("%d",arr[i]);
}
}
int main(){
int N,M;
scanf("%d%d",&N,&M);
M%=N;//化简移动次数
for(int i=1;i<=N;i++){//从1开始存储
scanf("%d",&arr[i]);
}
Priarr(N-M+1,N);
if(N-M+1<N)printf(" ");
Priarr(1,N-M);
return 0;
}
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
int N, M;
cin >> N >> M;
int a[N];
for (int i = 0; i < N; i++)
scanf("%d",&a[i]);
M %= N;
if (M != 0) {
reverse(a, a+N);
reverse(a, a+M);
reverse(a+M, a+N);
}
for (int i = 0; i < N - 1; i++)
printf("%d ",a[i]);
printf("%d",a[N-1]);
return 0;
}
标签:src code scanf 数组 开始 tor images iar 存储
原文地址:https://www.cnblogs.com/hebust/p/9813279.html