notes on extremes

From ggc

Jump to: navigation, search

set extreme to first value

go through the remaining values and if value

excede then replace the extreme with that value

code:

int min=nums[0];

System.out.println("Starting minimum: "+min);

for(int i=1; i<nums.length; i++) {

 if(nums[i]<min)
 {
   System.out.println("Minimum is now "+min);
   min=nums[i];
 }
 System.out.println("Finally, the minimum is "+min);

}





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter