当前位置:网站首页>1008 数组元素循环右移问题 (20 分)
1008 数组元素循环右移问题 (20 分)
2022-08-05 05:16:00 【呆比特】
1008 数组元素循环右移问题 (20 分)
题目要求:
代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//輸入
int n = scan.nextInt();
int m = scan.nextInt();
scan.nextLine();
//直接在輸入时就按照要求的顺序保存
int [] arr = new int[n];
//n = m
if (n == m){
for (int i = 0; i < n; i++) {
arr[i] = scan.nextInt();
}
}
//防止移动数大于数组长度
int k = m % n;
for (int i = k; i < n; i++) {
arr[i] = scan.nextInt();
}
for (int i = 0; i < k; i++) {
arr[i] = scan.nextInt();
}
//输出
for (int i = 0; i < n; i++) {
if (i == n-1){
System.out.print(arr[i]);
} else{
System.out.print(arr[i] + " ");
}
}
}
}
结果:
边栏推荐
- 单变量线性回归
- 九、响应处理——内容协商底层原理
- 【数据库和SQL学习笔记】3.数据操纵语言(DML)、SELECT查询初阶用法
- 关于使用QML的MediaPlayer实现视频和音频的播放时遇到的一些坑
- 【Pytorch学习笔记】8.训练类别不均衡数据时,如何使用WeightedRandomSampler(权重采样器)
- 【论文阅读-表情捕捉】High-quality Real Time Facial Capture Based on Single Camera
- [Kaggle project actual combat record] Steps and ideas sharing of a picture classification project - taking leaf classification as an example (using Pytorch)
- [After a 12] No record for a whole week
- 网络ID,广播地址,掩码位数计算
- 如何跟踪网络路由链路&检测网络健康状况
猜你喜欢

AIDL详解

CVPR2020 - 自校准卷积

九、响应处理——内容协商底层原理

IT系统运行维护方法及策略

Comparison and summary of Tensorflow2 and Pytorch in terms of basic operations of tensor Tensor
![[Database and SQL study notes] 9. (T-SQL language) Define variables, advanced queries, process control (conditions, loops, etc.)](/img/7e/566bfa17c5b138d1f909185721c735.png)
[Database and SQL study notes] 9. (T-SQL language) Define variables, advanced queries, process control (conditions, loops, etc.)

CVPR 2022 | 70% memory savings, 2x faster training

Detailed explanation of BroadCast Receiver (broadcast)

【Kaggle项目实战记录】一个图片分类项目的步骤和思路分享——以树叶分类为例(用Pytorch)
![[Database and SQL study notes] 8. Views in SQL](/img/22/82f91388f06ef4f9986bf1e90800f7.png)
[Database and SQL study notes] 8. Views in SQL
随机推荐
【论文精读】ROC和PR曲线的关系(The relationship between Precision-Recall and ROC curves)
MaskDistill-不需要标注数据的语义分割
CVPR最佳论文得主清华黄高团队提出首篇动态网络综述
Service
物联网:LoRa无线通信技术
【论文阅读-表情捕捉】ExpNet: Landmark-Free, Deep, 3D Facial Expressions
AIDL detailed explanation
flink部署操作-flink on yarn集群安装部署
ECCV2022 | RU & Google propose zero-shot object detection with CLIP!
Flink Oracle CDC写入到HDFS
[Practice 1] Diabetes Genetic Risk Detection Challenge [IFLYTEK Open Platform]
CVPR 2022 |节省70%的显存,训练速度提高2倍
记我的第一篇CCF-A会议论文|在经历六次被拒之后,我的论文终于中啦,耶!
Mysql-连接https域名的Mysql数据源踩的坑
【论文精读】R-CNN 之预测框回归(Bounding box regression)问题详述
CAN、CAN FD
Redis设计与实现(第三部分):多机数据库的实现
【数据库和SQL学习笔记】7.SQL中的插入(INSERT)、删除(DELETE)、更新(UPDATE)
【ts】typescript高阶:分布式条件类型
全尺度表示的上下文非局部对齐