Pagini recente » Cod sursa (job #789857) | Cod sursa (job #3217681) | Cod sursa (job #919354) | Cod sursa (job #1360155) | Cod sursa (job #538356)
Cod sursa(job #538356)
#include <iostream>
using namespace std;
int main()
{
int n;
cin >>n;
int a[n+5];
int i,min,min_i;
for(i=1;i<=n;i++)
cin>>a[i];
min = a[1];
min_i = 1;
for(i=1;i<=n;i++)
{
cout<<a[i]<<' ';
}
int k,val;
cin >>k>>val;
n++;
for(i=n;i>=k+1;i--)
{
a[i] = a[i-1];
}
a[k] = val;
cout<<endl;
//n++;
int max=a[1];
for(i=1;i<=n;i++)
{
if(a[i] < min)
{
min = a[i];
min_i = i;
}
if(a[i] > max)
max = a[i];
//cout<<a[i]<<' ';
}
k = min_i+1;
n++;
for(i=n;i>=k+1;i--)
a[i] = a[i-1];
a[k] = max;
for(i=1;i<=n;i++)
cout<<a[i]<<' ';
return 0;
}