fork download
  1. #include<iostream>
  2. #define f0n for (int i = 0; i < n; i++)
  3. using namespace std;
  4. int main() {
  5. int arr[100], n, maximum = -1e9,max2 = -1e9,max3 = -1e9;
  6. cin >> n;
  7. for (int i = 0; i < n; i++) {
  8. cin >> arr[i];
  9. }
  10. for (int i = 0; i < n; i++) {
  11. maximum = max(maximum, arr[i]);
  12. }
  13. for (int i = 0; i < n; i++) {
  14. if (max2 < arr[i] && arr[i] < maximum) {
  15. max2 = arr[i];
  16. }
  17. }
  18. for (int i = 0; i < n; i++) {
  19. if (max3 < arr[i] && arr[i] < max2) {
  20. max3 = arr[i];
  21. }
  22. }
  23. cout << maximum << " " << max2 << " " << max3;
  24. }
Success #stdin #stdout 0.01s 5280KB
stdin
10 
2432 3242 324 23432 43242 234 324 42332 3232 2324
stdout
43242 42332 23432