当前位置:网站首页>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] + " ");
}
}
}
}
结果:
边栏推荐
- tensorflow的session和内存溢出
- Web Component-处理数据
- 单片机按键开发库-支持连击、长按等操作
- 如何跟踪网络路由链路&检测网络健康状况
- 读论文- pix2pix
- [Database and SQL study notes] 10. (T-SQL language) functions, stored procedures, triggers
- SSL 证书签发详细攻略
- SharedPreferences和SQlite数据库
- Thread handler句柄 IntentServvice handlerThread
- 【Pytorch学习笔记】11.取Dataset的子集、给Dataset打乱顺序的方法(使用Subset、random_split)
猜你喜欢

【Pytorch学习笔记】10.如何快速创建一个自己的Dataset数据集对象(继承Dataset类并重写对应方法)
![[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)
![[Pytorch study notes] 10. How to quickly create your own Dataset dataset object (inherit the Dataset class and override the corresponding method)](/img/71/f82e76085f9d8e6610f6f817e2148f.png)
[Pytorch study notes] 10. How to quickly create your own Dataset dataset object (inherit the Dataset class and override the corresponding method)

盘点关于发顶会顶刊论文,你需要知道写作上的这些事情!
![[Intensive reading of the paper] R-CNN's Bounding box regression problem is detailed](/img/ef/a058ec08bd0a6313e3610a4ebc9685.png)
[Intensive reading of the paper] R-CNN's Bounding box regression problem is detailed

华科提出首个用于伪装实例分割的一阶段框架OSFormer

BroadCast Receiver(广播)详解

Tensorflow2 与 Pytorch 在张量Tensor基础操作方面的对比整理汇总

读论文- pix2pix

Flutter 3.0升级内容,该如何与小程序结合
随机推荐
flink项目开发-flink的scala shell命令行交互模式开发
【数据库和SQL学习笔记】8.SQL中的视图(view)
【Pytorch学习笔记】9.分类器的分类结果如何评估——使用混淆矩阵、F1-score、ROC曲线、PR曲线等(以Softmax二分类为例)
PID详解
六步搞定子网划分
[Practice 1] Diabetes Genetic Risk Detection Challenge [IFLYTEK Open Platform]
【论文阅读-表情捕捉】ExpNet: Landmark-Free, Deep, 3D Facial Expressions
ECCV2022 | RU&谷歌提出用CLIP进行zero-shot目标检测!
全尺度表示的上下文非局部对齐
数据库期末考试,选择、判断、填空题汇总
5G中切片网络的核心技术FlexE
2021电赛资源及经验总结
MaskDistill-不需要标注数据的语义分割
如何编写一个优雅的Shell脚本(二)
数控直流电源
A deep learning code base for Xiaobai, one line of code implements 30+ attention mechanisms.
初识机器学习
基于STM32F407的WIFI通信(使用的是ESP8266模块)
[Skill] Long-term update
Web Component-处理数据