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