参考代码:
import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int[] arr = new int[n]; int[] arr2 = new int[n]; for (int i = 0; i < n; i++) { arr[i] = sc.nextInt(); } int m = sc.nextInt(); int a = m; for (int i = 0; i < n; i++) { if (i < m){ arr2[i] = arr[arr.length-a]; a--; }else{ arr2[i] = arr[i-m]; } System.out.print(arr2[i]+" "); } } }
0.0分
2 人评分
C语言训练-求矩阵的两对角线上的元素之和 (C++代码)浏览:806 |
C语言程序设计教程(第三版)课后习题7.5 (C语言代码)浏览:609 |
永远的丰碑 (C语言代码)浏览:656 |
打水问题 (C语言代码)浏览:1072 |
printf基础练习2 (有点不明白)浏览:845 |
C语言训练-计算t=1+1/2+1/3+...+1/n (C语言代码)浏览:908 |
数对 (C语言代码)浏览:702 |
Tom数 (C语言代码)浏览:725 |
Pascal三角 (C语言代码)浏览:653 |
C语言程序设计教程(第三版)课后习题5.7 (C语言代码)浏览:785 |