Sửa phần tử trong mảng C++

[C++] Nhập mảng và thêm, xóa phần tử trong mảng
Phần mềm sử dụng: Visual Studio

CODE:

Select All

#include 
#include 
#define max 100
void nhapmang(int a[], int n)
{
    for (
int i 0n;i++)
    {
        
printf("Nhap vao a[%d]="i);
        
scanf_s("%d", &a[i]);
    }
}
void xuatmang(int a[], int n)
{
    for (
int i 0ni++)
    {
        
printf("%4d"a[i]);
    }
}
void themphantu(int a[], int &nint posint t)
{
    for (
int i n>= pos 1;i--)
    {
        
a[i] = a[1];
    }
    
a[pos] = t;
    
n++;
}
void xoaphantu(int a[], int &nint vtx)
{
    for (
int i vtx<= n-1i++)
    {
        
a[i] = a[1];
    }
    
n--;

}
int main()
{
    
int a[max],n,pos=2,t=69;
    do
    {
        
printf("Nhap so phan tu:");
        
scanf_s("%d", &n);
        if (
n<0||n>max)
        {
            
printf("nhap sai.Xin kiem tra lai!");
        }
    } while (
n<|| n>max);
    
nhapmang(an);
    
xuatmang(an);
    do{
        
printf("\nNhap vi tri phan tu can them (%d ----> %d): ",0,n);
        
scanf_s("%d", &pos);

        if (
pos<0||pos>n)
        {
            
printf("Ban nhap sai vi tri them. Ban hay kiem tra lai!");
        }

    } while (
pos<|| pos >n);
    
printf("\nNhap gia tri can them:");
    
scanf_s("%d", &t);

   
    
themphantu(anpost);
    
xuatmang(an);
    do{
        
printf("\nNhap vi tri phan tu can xoa (%d ----> %d): "0n);
        
scanf_s("%d", &pos);

        if (
pos<|| pos>n)
        {
            
printf("Ban nhap sai vi tri xoa. Ban hay kiem tra lai!");
        }

    } while (
pos<|| pos >n);
    
xoaphantu(anpos);
    
xuatmang(an);
    
_getch();
}