JAVA 面试题 写一个内部工具类
来源:百度知道 编辑:UC知道 时间:2024/07/02 02:52:16
package com.chen.model;
public class MaxMin {
private int[] shuzu;
public MaxMin(int [] a){
this.shuzu=a;
}
public int max;
public int min;
//先执行排序算法 然后调值就行了
public void paixu() {
//01.先将最大的书放到最后
int count = 0;
boolean exchange = false;
for (int j = 0; j < shuzu.length -1; j++)
{
exchange = false;
for (int i = 0;i< shuzu.length - j - 1; i++)
{
count++;
if (shuzu[i] > shuzu[i + 1])
{
//标准交换算法
int temp = 0;
temp = shuzu[i];
shuzu[i] = shuzu[i + 1];
shuzu[i + 1] = temp;
exchange = true;
}
}
if (exchange == false)
{