Well, lets take a simple problem:
Input 3 numbers(integer) and find out the smallest one.
In how many simple ways can it be solved?
Dear all, now you keep posting the ways to solve it. Then I shall comment on them, possibly individually!
Remember: use bluej only.
class Check
ReplyDelete{
public void disp(int a,int b,int c)
{
if((a<b)&&(a<c))
System.out.println(a);
if((c<b)&&(c<a))
System.out.println(c);
if((b<a)&&(b<c))
System.out.println(b);
}
or
public void disp(int a,int b, int c)
{
int s=a;
if(b<s)
s=b;
if(c<s)
s=c;
System.out.println(s);
}
Good. But why checking the 2nd and 3rd if with full condition in the first answer? We can still minimise it by eliminating the variables from conditions one by one.
ReplyDeleteThink about it.