Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Max.cpp : This file contains the 'main' function. Program execution begins and ends there.
- // Bài 3 || Huỳnh Thế Anh
- #include <iostream>
- using namespace std;
- int main()
- {
- int arr[1000];
- int n;
- cin >> n;
- for (int i = 0; i < n; i++)
- {
- cin >> arr[i];
- }
- // process
- int m1 = 0, m2 = 0, m3 = 0;
- for (int i = 0; i < n; i++)
- {
- if (arr[i] > m1)
- {
- m3 = m2;
- m2 = m1;
- m1 = arr[i];
- }
- else if (arr[i] > m2)
- {
- m3 = m2;
- m2 = arr[i];
- }
- else if ( arr[i] > m3) m3 = arr[i];
- }
- cout << m1 << " " << m2 << " " << m3;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement