当前位置:网站首页>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] + " ");
}
}
}
}
结果:
边栏推荐
- 《基于机器视觉测量系统的工业在线检测研究》论文笔记
- Flink和Spark中文乱码问题
- [After a 12] No record for a whole week
- 【论文阅读-表情捕捉】High-quality Real Time Facial Capture Based on Single Camera
- Tensorflow2 与 Pytorch 在张量Tensor基础操作方面的对比整理汇总
- SparkML-初探-文本分类
- Thread handler句柄 IntentServvice handlerThread
- 大型Web网站高并发架构方案
- Detailed explanation of BroadCast Receiver (broadcast)
- 11%的参数就能优于Swin,微软提出快速预训练蒸馏方法TinyViT
猜你喜欢
![[Kaggle project actual combat record] Steps and ideas sharing of a picture classification project - taking leaf classification as an example (using Pytorch)](/img/7d/7f1301c30034f1c247d41f04c40244.png)
[Kaggle project actual combat record] Steps and ideas sharing of a picture classification project - taking leaf classification as an example (using Pytorch)

【Shell编程】第一章:子串

CVPR 2020 - 频谱正则化

CAN、CAN FD

Flutter 3.0升级内容,该如何与小程序结合

Mysql-连接https域名的Mysql数据源踩的坑

神经网络也能像人类利用外围视觉一样观察图像

OSPF故障排除办法
![[Pytorch study notes] 11. Take a subset of the Dataset and shuffle the order of the Dataset (using Subset, random_split)](/img/59/ce3e18f32c40a97631f5ac1b53662a.png)
[Pytorch study notes] 11. Take a subset of the Dataset and shuffle the order of the Dataset (using Subset, random_split)

MSRA提出学习实例和分布式视觉表示的极端掩蔽模型ExtreMA
随机推荐
单片机按键开发库-支持连击、长按等操作
CVPR 2022 | 70% memory savings, 2x faster training
伪RTOS-ProroThread在CH573芯片上的移植
读论文-Cycle GAN
CH32V307 LwIP移植使用
[Database and SQL study notes] 9. (T-SQL language) Define variables, advanced queries, process control (conditions, loops, etc.)
网络ID,广播地址,掩码位数计算
物联网:LoRa无线通信技术
IT系统运行维护方法及策略
[Pytorch study notes] 9. How to evaluate the classification results of the classifier - using confusion matrix, F1-score, ROC curve, PR curve, etc. (taking Softmax binary classification as an example)
Flutter 3.0升级内容,该如何与小程序结合
神经网络也能像人类利用外围视觉一样观察图像
Kubernetes常备技能
Day1:用原生JS把你的设备变成一台架子鼓!
Flink Oracle CDC写入到HDFS
CAN、CAN FD
读论文 - Unpaired Portrait Drawing Generation via Asymmetric Cycle Mapping
spingboot 容器项目完成CICD部署
SSL 证书签发详细攻略
发顶会顶刊论文,你应该这样写作