package test;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Test {
public static void main(String args[]) {
System.out.println("请输入三个数,使用','分隔:");
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
String tempString = "";
while (null != (tempString = br.readLine())) {
if (tempString.equals("exit")) {
break;
}
String[] strs = tempString.split("[, ,]");
int[] result;
System.out.println("---input tempString =[" + tempString + "]"); // 换行
if(null!=strs&&strs.length>0)
{
result = new int[strs.length];
for(int num=0;num
//冒泡排序
int temp;
for (int i = 0; i < result.length; ++i) {
for (int j = 0; j < result.length - i - 1; ++j) {
if (result[j]-result[j + 1] > 0 ) {
temp = result[j];
result[j] = result[j + 1];
result[j + 1] = temp;
}
}
}
System.out.print("输入数据【"+tempString+"】升序排列结果:");
for(int i=0;i
System.out.print(result[i]+",");
}
System.out.println("");
System.out.println("推出请输入:exit;继续请输入三个数,使用','分隔:");
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
import java.util.Arrays;
import java.util.Scanner;
public class DataCompare {
public static void main(String[] args) {
int[] ary = new int[3];
Scanner scanner = new Scanner(System.in);
for(int i = 0; i < ary.length; i++){
System.out.print("Please input a digit(Seq: " + (i+1) + "): ");
ary[i] = scanner.nextInt();
}
Arrays.sort(ary);
System.out.print("After sorted by ASC, the numbers are: ");
for(int i = 0; i < ary.length; i++){
System.out.println(ary[i] + "\t");
}
}
}
--------------------------testing
Please input a digit(Seq: 1): 13
Please input a digit(Seq: 2): 25
Please input a digit(Seq: 3): 9
After sorted by ASC, the numbers are: 9
13
25
/**
* copyright (c) by 电子所 2011
*/
/**
* @author:zhl
* E-mail: 123230828@qq.com
* @date:2011-9-13 下午12:23:50
*/
public class Test {
public void aa(int a,int b,int c){
int [] ss=new int[3];
if(a-b>=0){
if(b-c>=0){
ss[0]=a;
ss[1]=b;
ss[2]=c;
}else{
if(a-c>=0){
ss[0]=a;
ss[1]=c;
ss[2]=b;
}else{
ss[0]=c;
ss[1]=a;
ss[2]=b;
}
}
}else{
if(b-c>=0){
if(a-c>=0){
ss[0]=b;
ss[1]=a;
ss[2]=c;
}else{
ss[0]=b;
ss[1]=c;
ss[2]=a;
}
}else{
ss[0]=c;
ss[1]=b;
ss[2]=a;
}
}
for(int i=0;i
}
}
public static void main(String[] args){
Test t=new Test();
t.aa(39, 40, 30);
}
}