Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void relax(int& a, int& b) {
- if (a > b) b = a;
- }
- int main() {
- int n;
- cout << "Enter size of array: ";
- cin>> n;
- int* a = new int[n];
- cout<< "Enter your array: "<<endl;
- for (int i = 0; i < n; ++i)
- cin >> a[i];
- int mx = 0;
- for (int i = 0; i < n; ++i) {
- if (i % 2) relax(a[i], mx);
- }
- cout<< "max = "<< mx<< endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement