Java第三章40页例3-1(对整数排序)
2016-09-13 11:27
543 查看
Number 类
Test 类
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class Test {
public static void main(String[] args){
// int a,b,c;
// Input ip=new Input();
// a=ip.scan();
Number num=new Number();
num.sort(88, 77,22);
}
}
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author Administrator */ public class Number { public void sort(int a,int b,int c){ int count=0; int temp=0; if(a>b){ temp=a; a=b; b=temp; count=count+1; System.out.println("the count is "+count+" and the result is "+a+" "+b+" "+c); } if(a>c){ temp=a; a=c; c=temp; count=count+1; System.out.println("the count is "+count+" and the result is "+a+" "+b+" "+c); } if(b>c){ temp=b; b=c; c=temp; count=count+1; System.out.println("the count is "+count+" and the result is "+a+" "+b+" "+c); } if(count==0){ System.out.println("the count is "+count+" and the result is "+a+" "+b+" "+c); } } }
Test 类
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author Administrator
*/
public class Test {
public static void main(String[] args){
// int a,b,c;
// Input ip=new Input();
// a=ip.scan();
Number num=new Number();
num.sort(88, 77,22);
}
}
相关文章推荐
- java调.NET webapi时间戳报错问题
- Java 实现 堆排序 快速排序 以及 TopK问题(一)
- JavaSE 异常
- Spring boot读取配置文件
- 4种方法让SpringMVC接收多个对象
- 性能分析工具之-- Eclipse Memory Analyzer tool(MAT)(二)
- java垃圾回收机制
- Java多线程学习
- java Collection集合删除某一元素方法汇总
- java关键字的适用总结
- java基础03
- eclipse如何调试system_server
- Struts2入门-Hello Word实例
- eclipse下maven web项目的创建
- 在ECLIPSE中开发CASSANDRA
- [解决]java.io.IOException: Cannot obtain block length for LocatedBlock
- 触摸Java常量池
- JAVA笔试题笔记(三)
- Java利用json-lib操作json
- 性能分析工具之-- Eclipse Memory Analyzer tool(MAT)(一)