#include "iostream.h"
#include "conio.h"
void nhap(int a[],int n)
{
for(int i=0;i<n;i++)
{
cout<<"a["<<i<<"]=";
} }
// xuat mang
void xuat(int a[],int n)
{
for(int i=0;i<n;i++)
cout<<a[i]<<" ";
}
// chen phan tu vao mang
void chen(int a[],int n,int vt,int x)
{
if(vt>=0 && vt<=n)
{
for(int i=0;i>vt;i )
n++;
} }
// xoa phan tu
void xoa(int a[],int n,int cx)
{
if(cx>=0 && cx<=n)
{
for(int i=cx;i<n-1;i++)
Trang 2a[i]=a[i+1];
n=n-1;
}
}
// ham chinh
main ()
cout<<" xin nhap vao so phan tu cua mang: n= "; cin>>n;
nhap(b,n);
cout<<endl<<" mang vua nhap la: "<<endl;
xuat(b,n);
cout<<endl<<"xin nhap so can chen: x= "; cin>>x; cout<<endl<<"xin nhap vi tri can chen: vt= "; cin>>vt;
chen(b,n,vt,x);
cout<<endl<<" mang vua chen xong la: "<<endl;
xuat(b,n);
cout<<endl<<"xin nhap vi tri can xoa: cx= "; cin>>cx;
xoa(b,n,cx);
cout<<endl<<"mang sau khi xoa la: "<<endl;
xuat(b,n);
getch ();
}