Fork me on GitHub

倒序输出(指针方法)

题目:输入3个数a,b,c,按大小顺序输出。

        int[] arrays = { 800, 56, 500 };
        for (int i = arrays.length; --i >= 0;) {
            for (int j = 0; j < i; j++) {
                if (arrays[j] > arrays[j + 1]) {
                    int temp = arrays[j];
                    arrays[j] = arrays[j + 1];
                    arrays[j + 1] = temp;
                }
            }
        }
        for (int n = 0; n < arrays.length; n++)
            System.out.println(arrays[n]);

源码

 

posted @ 2017-12-12 22:33  秋夜雨巷  阅读(995)  评论(0编辑  收藏  举报