Assignment-csea3523
Submit solution
C
Points:
20 (partial)
Time limit:
1.5s
Memory limit:
64M
Author:
Problem type
Allowed languages
Write C Code to Delete an element from a specified position. Handle index error with message "error in index number"
Input 5 1 2 3 4 5 3
output 4 1 2 3 5
Comments
include <stdio.h>
int main() { int n,i,p,t; scanf("%d",&n); int a[n]; for(i=0;i<=n-1;i++) { scanf("%d",&a[i]); }
}
include <stdio.h>
int main() { int n,i,p,t; scanf("%d",&n); int a[n]; for(i=0;i<=n-1;i++) { scanf("%d",&a[i]); }
}
include <stdio.h>
int main(){ int n,i,p,t; scanf("%d",&n); int a[n]; for(i=0;i<=n-1;i++){ scanf("%d",&a[i]); } scanf("%d",&p); t=a[p]; if(p>n-1 ||p<0){ printf("error in index number"); } else{ for(i=p;i<=n-2;i++){ a[i]=a[i+1]; } printf("%d\n",t); for(i=0;i<=n-2;i++){ printf("%d\n",a[i]); } }
}