1)
#include <iostream>
using namespace std;
signed main(){
int n, res = 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
res = max(res, abs(a[i] - a[0]));
}
cout << res;
2)
int n, mn_val = 1e9, mn_in = 0;
if(a[i] < mn_val){
mn_val = a[i];
mn_in = i;
swap(a[mn_in], a[n-1]);
for(int i = 0; i < n; i++)
cout << a[i] << " ";
3)
int n, mx = -1e9;
if(a[i] < 0)
mx = max(mx, a[i]);
cout << mx;
4)
int n, mx1 = -1e9, mx2 = -1e9;
if(a[i] > mx1){
mx2 = mx1;
mx1 = a[i];
else if(a[i] > mx2)
mx2 = a[i];
cout << mx2;
1)
#include <iostream>
using namespace std;
signed main(){
int n, res = 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
res = max(res, abs(a[i] - a[0]));
}
cout << res;
}
2)
#include <iostream>
using namespace std;
signed main(){
int n, mn_val = 1e9, mn_in = 0;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] < mn_val){
mn_val = a[i];
mn_in = i;
}
}
swap(a[mn_in], a[n-1]);
for(int i = 0; i < n; i++)
cout << a[i] << " ";
}
3)
#include <iostream>
using namespace std;
signed main(){
int n, mx = -1e9;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] < 0)
mx = max(mx, a[i]);
}
cout << mx;
}
4)
#include <iostream>
using namespace std;
signed main(){
int n, mx1 = -1e9, mx2 = -1e9;
cin >> n;
int a[n];
for(int i = 0; i < n; i++){
cin >> a[i];
if(a[i] > mx1){
mx2 = mx1;
mx1 = a[i];
}
else if(a[i] > mx2)
mx2 = a[i];
}
cout << mx2;
}