首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java相关 >

初学者求教。这两题如何破

2013-07-08 
菜鸟求教。这两题怎么破才接触Java 没多久、弱弱问下。Java基础[解决办法]不是吧,考试题?sort3 (a,b,c)publi

菜鸟求教。这两题怎么破
初学者求教。这两题如何破初学者求教。这两题如何破
   才接触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){


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;
}
}

热点排行