• 题目要求:不能使用新数组,就用原来的唯一的数组进行反转


    package cn.itcast.day05.demo03;

    /**
    * @author newcityman
    * @date 2019/7/4 - 0:36
    * 题目要求:不能使用新数组,就用原来的唯一的数组进行反转
    * 分析1、对称位置交换
    * 2、需要两个位置索引
    * 3、两个数要进行交换,需要借助第三个数
    */
    public class Demo07Reverse {
    public static void main(String[] args) {
    int[] array ={15,52,24,36,9,6,87};
    for (int i = 0; i < array.length; i++) {
    System.out.print(array[i]+" ");
    }
    System.out.println();
    System.out.println("++++++++++++++++++++++++++++");
    int temp;
    for (int min = 0,max=array.length-1; min <= max; min++,max--) {
    temp = array[min];
    array[min] =array[max];
    array[max] =temp;
    }
    for (int i = 0; i < array.length; i++) {
    System.out.print(array[i]+",");
    }
    }
    }
  • 相关阅读:
    尚未笔记知识点
    jsonp的原理及其使用
    django中将views.py中的python方法传递给html模板文件
    UVA
    UVA
    UVA
    UVA
    UVA
    UVA 1600 Patrol Robot
    UVA
  • 原文地址:https://www.cnblogs.com/newcityboy/p/11130020.html
Copyright © 2020-2023  润新知