翻转数组
来源:互联网 发布:天互数据 垃圾 编辑:程序博客网 时间:2024/05/12 09:45
/*Enter 10 digits number: 11 12 13 14 15 16 17 18 19 20The reverse digits number: 20 19 18 17 16 15 14 13 12 11 */import java.util.Scanner;public class ReverseDigits { public static void main(String[] args) { Scanner input = new Scanner(System.in); final int SIZE = 10; int[] n = new int[SIZE]; System.out.print("Enter 10 digits number: "); for (int i = 0; i < SIZE; i++) n[i] = input.nextInt(); int[] reverseN = reverse(n); System.out.print("The reverse digits number: "); show(reverseN); } public static void show(int[] n) { for (int i = 0; i < n.length; i++) System.out.print(n[i] + " "); System.out.println(); } public static int[] reverse(int[] n) { int[] reverseN = new int[n.length]; int j = n.length - 1; for (int i = 0; i < n.length; i++) reverseN[j--] = n[i]; return reverseN; }}
0 0
- 数组翻转
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 翻转数组
- 数组翻转
- 翻转数组
- 翻转数组
- 数组翻转
- [算法]翻转数组
- sql语句
- Jenkins + Gradle + Android
- Spring Aop 配置
- Mac上Homebrew的使用 (Homebrew 使 OS X 更完整)
- JavaScript中使用arguments获得函数传参个数实例
- 翻转数组
- 华为OJ(字符串运用-密码截取)
- JQuery开发权威指南——学习笔记
- 文章标题
- hdu5405 Sometimes Naive
- BrowseForFolder使用,参数详解
- 启动程序注入DLL
- 踩诖菲毓俾春荡诚盼退笛钠拘儆刈烤沤
- android 自定义View之SubmitView