嘿,我正在研究一种方法,从两个传递的整数中选取最小的数字,然后返回一个由最小值组成的整数地点。例如,如果int a = 4321和int b = 1957,那么该方法将返回1321.这是我的代码到目前为止,我想我得到了一切,但我无法找到如何正确返回新值作为整数。作为一个单一的值返回多个整数
public static int biggestLoser(int a, int b){
int first;
int second;
int third;
int fourth;
if(a>9999 || a<1000 || b>9999 || b<1000){
if(a>b)
return b;
else
return a;
}
else{
if(a%10 < b%10)
first=a%10;
else
first=b%10;
if(a/1000<b/1000)
fourth=a/1000;
else
fourth=b/1000;
if(a/100%10<b/100%10)
second=a/100%10;
else
second=b/100%10;
if(a/10%10<b/10%10)
third=a/10%10;
else
third=b/10%10;
//int total=fourth,third,second,first;?????
//return total;
}
}
考虑按10乘以增加,就像你在纸上做的一样。不要让它变得更复杂,那就是 - 基本的3级算术。 – 2014-09-23 02:07:54