You are on page 1of 1

#include <iostream>

using namespace std;

int main()
{
int c, a, k, p;
int V[100];
int T[100];
cout << "Introduceti numarul de variabile din multimea A: ";
cin >> a;

cout << "Introduceti " << a << " variabile: ";


for (c = 0; c < a; c++) {
cin >> V[c];
}
for (c = 0; c < a; c++) {
cout << "V[" << c << "] = " << V[c] << " " << " - pozitia " << c + 1 <<
endl;
}

cout << "Introduceti termenul k: ";


cin >> k;
cout << "Introduceti pozitia pe care sa apara termenul k: ";
cin >> p;

for (c = p; c < a + 1; c++) {


T[c] = V[c - 1];
}
V[p - 1] = k;
for (c = 0; c < p; c++) {
cout << "V[" << c << "] = " << V[c] << " " << " - pozitia " << c + 1 <<
endl;
}
for (c = p; c <= a; c++) {
cout << "V[" << c << "] = " << T[c] << " " << " - pozitia " << c
+ 1 << endl;
}
cout << "Vechiul sir este: ";
for (c = 0; c < p - 1; c++) {
cout << V[c] <<" ";
}
for (c = p; c <= a; c++) {
cout << T[c] << " ";
}
cout << " ";
cout << "Noul sir este: ";
for (c = 0; c < p; c++) {
cout << V[c] << " ";
}
for (c = p; c <= a; c++) {
cout << T[c] << " ";
}
}

You might also like