Given three int values, A B C, return the largest.
intMax(1, 2, 3) ? 3
intMax(1, 3, 2) ? 3
intMax(3, 2, 1) ? 3
public int intMax(int a, int b, int c) {
if(a>b)
if(a>c) return a;
else return c;
else if(b>c) return b;
else return c;
}
Given three int values, A B C, return the largest.
intMax(1, 2, 3) ? 3
intMax(1, 3, 2) ? 3
intMax(3, 2, 1) ? 3
public int intMax(int a, int b, int c) {
if(a>b)
if(a>c) return a;
else return c;
else if(b>c) return b;
else return c;
}
This entry was posted on Monday, January 11th, 2010 and is filed under Java. You can follow any responses to this entry through RSS 2.0. You can leave a response, or trackback from your own site.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jun | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
powered by WordPress
Entries (RSS) and Comments (RSS) ^
Recent Comments