Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class main {
- public static void main(String[] args) {
- int B[] = {8, 4, 5, 10, 13, 15, 12};
- System.out.println(BaSoLonNhat(B));
- }
- public static String BaSoLonNhat(int B[]) {
- int max1 = 0, max2 = 0, max3 = 0;
- int dem = 0;
- int vt = 0, vt1 = 0;
- for (int i = 0; dem < 3; i++) {
- if (dem == 0) {
- if (max1 <= B[i]) {
- max1 = B[i];
- vt = i;
- }
- }
- if (dem == 1) {
- if (max2 <= B[i] && i != vt) {
- max2 = B[i];
- vt1 = i;
- }
- }
- if (dem == 2) {
- if (max3 <= B[i] && i != vt && i != vt1) {
- max3 = B[i];
- }
- }
- if (i == B.length - 1) {
- i = 0;
- dem += 1;
- }
- }
- return max1 + " " + max2 + " " + max3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement