Răspuns :
Răspuns:
#include <iostream>
using namespace std;
int main(){
int v[101],m,n,pos=0,cnt=0;
cin>>n;
cin>>m;
for(int i=1;i<=n;i++){
cin>>v[i];
}
for(int i=1;i<=m;i++){
int nr;
cin>>nr;
for(int j=1;j<=n;j++){
if(v[j]==nr){
pos=j+1;
for(int k=pos;k<=n;k++){
v[k-1]=v[k];
}
}
}
n--;
}
for(int i=1;i<=n;i++){
cout<<v[i]<<" ";
}
}
Explicație:
Salut!
Ai rezolvarea in C++ mai jos
#include <iostream>
using namespace std;
int n, m;
int a[1201], b[1201];
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; ++i)
{
cin >> a[i];
}
for (int i = 1; i <= n - m; ++i)
{
cin >> b[i];
}
for (int i = 1; i <= n; ++i)
{
bool gasit = false;
for (int j = 1; j <= n - m; ++j)
{
if (a[i] == b[j])
{
gasit = true;
break;
}
}
if (!gasit)
{
cout << a[i] << " ";
}
}
return 0;
}