Threw you a solution in a hurry. Naturally, there are no checks for overflow of the array, etc., this is already add. If anything is not clear, ask! =)
#define _CRT_SECURE_NO_WARNINGS #include "stdafx.h" #include "stdio.h" #include "conio.h" #include <iostream> using namespace::std; int poisk(int B[], int temp, int n2) { int k=0; for (int i=0; i<n2; i++) { if (B[i]!=temp) k++; } if (k==n2) return 1; else return 0;
}
void del(int A[], int &n1, int i) { for (i; i<n1; i++) { A[i]=A[i+1]; } A[n1-1]=0; n1--; } int _tmain(int argc, _TCHAR* argv[]) { setlocale(LC_ALL, "Russian"); int A[10]; int B[10]; int n1=0,n2=0; int temp; cout<<"Введите количество элементов первого массива: "; cin>>n1; cout<<endl<<"Введите количество элементов второго массива: "; cin>>n2; cout<<"Вводим значения первого массива:"<<endl; for (int i=0; i<n1; i++) { cin>>A[i]; } cout<<"Вводим значения второго массива:"<<endl; for (int i=0; i<n2; i++) { cin>>B[i]; } cout<<endl; for (int i=0; i<n1; i++) { if (A[i]%2!=0) { temp=A[i]; if (poisk(B, temp, n2)) { del(A, n1, i); i--; } } } for (int i=0; i<n1; i++) { cout<<A[i]<<endl; } _getch(); return 0; }
n
? - VladD