#include<stdio.h>
int main()
{
int a[100],n,pos,val,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&val);
scanf("%d",&pos);
for(i=n;i>=pos;i--)
{
a[i]=a[i-1];
}
a[pos]=val;
n++;
for(i=0;i<n;i++)
printf(" %d",a[i]);
}
int main()
{
int a[100],n,pos,val,i;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&a[i]);
scanf("%d",&val);
scanf("%d",&pos);
for(i=n;i>=pos;i--)
{
a[i]=a[i-1];
}
a[pos]=val;
n++;
for(i=0;i<n;i++)
printf(" %d",a[i]);
}
i/p: 5
1 2 3 4 5
10
3
o/p: 1 2 3 10 4 5
No comments:
Post a Comment