|
Sep
25
|
One solution would be to loop through the array maintaining the smallest value found in a variable. Another solution would be to first sort the array, then the smallest value would be the first element.
int[] values = { 2, 67, 15, 3, 567 };
// first approach
int smallest = values[0];
for (int i=1; i<values.length; i++)
{
smallest = Math.min(smallest, values[i]);
}
// second approach
java.util.Arrays.sort(values);
smallest = values[0];



March 19th, 2010 at 7:08 pm
singkat banget ya ..
gmana lo kita di suruh ngoprasiin penjumlahan bilangan dengan type data masukan string.
tapi operasinya pake int, lalu hasilnya disimpan dalam bentuk string lagi??
August 24th, 2011 at 11:55 pm
hi what will be the code if you are asking for 10 random numbers then you will get its average and will show 4 least differentt number that you have inputed