Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int insert(int n, int a[], int position)
- {
- int j;
- for(j=position;j<n;j++){
- a[j]=a[j+1];
- }
- for(j=0;j<n-1;j++){
- printf("%d ", a[j]);
- }
- printf("\n");
- }
- int main()
- {
- int i, n;
- int position;
- int a[1000];
- scanf("%d", &n);
- for(i=0;i<n;i++)
- scanf("%d", &a[i]);
- scanf("%d", &position);
- if(position<=0 || position>n){
- printf("Invalid\n");
- return 0;
- }
- position--;
- insert(n,a,position);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment