using namespace std;
#include
int main()
{
int n;
成本<<"数组的大小 ;
cin>>n;
int t[n],index,Val;
for(int i=0;我{
成本<<"t[ <<我<<" ]= ";
cin>>t[i];
}
成本<<"在索引 i中插入一个新值<成本<<"键入从 0 到 < cin>>指数;
成本<<"键入 V 的值:;
cin>>山谷;
if(index<=n-1 &&index>=0 )
{
for(i=n-1;我>指数;i--)//最后一个元素将被覆盖
t[i]=t[i-1];
//当偏移量有限时,我们将值设置为选择的 index
t[index]=Val;
}
else{
cout<<"错误:索引超出了数组的大小;
}
//元素显示
成本<<"t = [ ;
for(i=0;我成本< 成本<<" ]";
system(暂停”);
}
Please disable your ad blocker and refresh the window to use this website.