Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- a[n]
- int maxa1 = -1, maxa2 = -1;
- int pos1 = 0, pos2 = -1;
- for (int i = 1; i <= n; i ++) {
- if (a[i] > maxa1) {
- maxa2 = maxa1;
- maxa1 = a[i];
- pos2 = pos1;
- pos1 = i;
- } else if (a[i] > maxa2) {
- maxa2 = a[i];
- pos2 = i;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement