Good afternoon, the task is to help find the error in the opcode to the task (The task is normal with acmp, once written in Pascal long ago, but now with C ++):
Two unordered sets of integers are given (maybe with repetitions). To issue without repetition in ascending order all those numbers that are found in both sets.
Input data
In the first line of the input file INPUT.TXT, two integers are written N and M (1 ≤ N, M ≤ 106) - the number of elements of the first and second sets, respectively. The following lines contain first the N numbers of the first set, and then the M numbers of the second set. Numbers are separated by spaces or line breaks. Each of these numbers falls in the range from 0 to 105.
Output
In the output file OUTPUT.TXT you need to write in ascending order without repeating all the numbers that are included in both the first and the second set. Separate numbers with one space. If there are no such numbers, the output file should remain empty.
Opcode:
#include "stdafx.h" #include <iostream> using namespace std; void main() { int M, N, i, j, f, g; int a[10], b[10]; cin >> N >> M; cout << "\n\n\n\n"; for (f = 0; f < N; f++) { cin >> a[f]; } cout << "\n\n\n\n"; for (g = 0; g < M; g++) { cin >> b[g]; } cout << "\n\n\n\n"; for (i = 0; i < N; i++) { for (j = 0; j < M; j++) ; { if (a[i] == b[j]) { cout << b[j]; } } } } I use 10 studio (I neglected to work with input and output files, I do not plan to donate to acmp). Please suggest where the error!