#include<iostream>
using namespace std;
void them(int a[], int pos, int emlement)
{
for (int i = 5; i >= pos ; i--)
{
a[i] = a[i - 1];
}
a[pos] = emlement;
}
/*
0--> 0
1--> 1
2--> 34
3--> 2
4--> 3
5--> 4
*/
int main()
{
int a[6] = { 0,1,2,3,4 };
them(a, 2, 34);// thêm phần tử 43 tại vị trí 2! { 0,1,34,2,3,4 };
for (int i = 0; i < 6; i++)
{
cout << a[i]<<" ";
}
system("pause");
return 0;
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.