日期:2014-05-20  浏览次数:20599 次

菜鸟求教。这两题怎么破

   才接触Java 没多久、   弱弱问下。
Java 基础

------解决方案--------------------
不是吧,考试题?
sort3 (a,b,c);
public void sort3

从小到大排
x>y  temple = x; x = y ; y = temple;
x>z  temple = x; x = z ; z = temple;
y>z  temple = y; y = z ; z = temple;

min3(a,b,c)

public int min3

int small;
后面的两个空格有问题,要不就是你的题目不完整
------解决方案--------------------
class MethodMedo2{
public static void main(String args[]){
int a=34,b=72,c=5,smallest;
sort3(a,b,c);
}
static void sort3(int x,int y,int z){
int temple;
if(x>y){
temple = x;
x = y;
y = temple;
}
if(x>z){
temple = x;
x = z;
z = temple;
}
if(y>z){
temple = y;
y = z;
z = temple;
}
System.out.println("Sorted:"+x+","+y+","+z);
return;
}
}

class MethodMedo1{
public static void main(String[] args){
int a=34,b=72,c=5,smallest;
smallest=min3(a,b,c);
System.out.println("the smallest is:"+smallest);
}
static int min3(int x,int y,int z){
int small;
small = Math.min(x,y);
small = Math.min(small,z);
return small;
}
}

------解决方案--------------------
class MethodMedo2{
public static void main(String args[]){
int a=34,b=72,c=5,smallest;
sort3(a,b,c);
}
static void sort3(int x,int y,int z){
int temple;
if(x>y){
temple = x;
x = y;
y = temple;
}
if(x>z){