SecondLargest
1. Question
- There are three integers, which integer is largest thing?
2. Solution
package
stepByStep;
import
java.util.Scanner;
public
class
SecondLargest {
public
static
void
main(String[]args){
Scanner br =
new
Scanner(System.in);
int
f = br.nextInt();
int
s = br.nextInt();
int
t = br.nextInt();
int
scale[] = {f,s,t};
int
temp;
if
(scale[
0
] < scale[
1
]){
temp = scale[
0
];
scale[
0
] = scale[
1
];
scale[
1
] = temp;
}
if
(scale[
1
] < scale[
2
]){
temp = scale[
1
];
scale[
1
] = scale[
2
];
scale[
2
] = temp;
}
if
(scale[
0
] < scale[
1
]){
temp = scale[
0
];
scale[
0
] = scale[
1
];
scale[
1
] = temp;
}
System.out.println(scale[
1
]);
}
}
'Algorithm&DataStructures > StepByStep' 카테고리의 다른 글
[Algorithm] 백준알고리즘_SelfNumber (0) | 2016.09.09 |
---|---|
[Algorithm] 백준알고리즘_SmallerThanX (0) | 2016.08.31 |
[Algorithm] 백준알고리즘_TestScore (0) | 2016.08.25 |
[Algorithm] 백준알고리즘_Sum (0) | 2016.08.24 |
[Algorithm] 백준알고리즘_2007 (0) | 2016.08.24 |