Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main()
{
int x;
cout<<"1 sau 2 ? :";
cin>>x;
if(x==1){
//1
int n,v[20],k=0;
cout<<"n: ";
cin>>n;
for(int i=1;i<=n;++i){
cin>>v[i];
}
for(int i=1;i<=n;++i){
if(v[i]<i){
cout<<v[i]<<" ";
k++;
}
}
if(k==0)
cout<<"NU EXISTA";
cout<<endl;
}else{
if(x==2){
//2
int n,v[42],k=0;
cout<<"n: ";
cin>>n;
for(int i=1;i<=2*n;++i){
cin>>v[i];
}
int aparitii;
for(int i=1;i<=n;++i){
aparitii=0;
for(int j=n+1;j<=2*n;++j){
if(v[i]==v[j]){
aparitii++;
k++;
}
}
if(aparitii>=1){
cout<<v[i];
}
}
if(k==0)
cout<<"nu exista";
cout<<endl;
}
}
return 0;
}
Explicație: