漳州建设项目公告网站,免费广告推广平台,如何自己做游戏网站,自媒体网站源码输入一个数组#xff0c;然后颠倒次序进行输出#xff0c;这种算法在程序开发中经常用到#xff0c;下面我们通过一个小实例来看看怎么实现在控制台输入一个数组#xff0c;并让其逆序输出的。源码#xff1a;import java.util.Scanner;public class Test01 {public stati…输入一个数组然后颠倒次序进行输出这种算法在程序开发中经常用到下面我们通过一个小实例来看看怎么实现在控制台输入一个数组并让其逆序输出的。源码import java.util.Scanner;public class Test01 {public static void main(String[] args){System.out.println(请输入五个数);int[]lnew int [5];for(int i0;i5;i)l[i]new Scanner(System.in).nextInt();Test01 sorternew Test01();sorter.ReverseSort(l);}public void ReverseSort (int[] l) {int lenl.length;for(int i0;iint templ[i];l[i]l[len-1-i];l[len-1-i]temp;}System.out.println(反转后);show(l);System.out.println();}public static void show(int[] l) {for(int i:l){System.out.print(i );}}}附Scanner是SDK1.5的时候增加的一个类用来获取控制台输入的参数还是比较重要的。将上述代码放到自己新建的类当中然后运行在运行结果里输入一组数回车即可。以上就是本文的全部内容希望对大家的学习有所帮助也希望大家多多支持脚本之家。